Commit graph

201 commits

Author SHA1 Message Date
Kynan Ware
bff468bafe fix(pr create): wire up @copilot assignee replacement and [bot] suffix
Two bugs introduced in #13009 found during acceptance testing:

1. `pr create --assignee @copilot` sent the literal `@copilot` to the
   API because NewIssueState only ran MeReplacer on assignees, not
   CopilotReplacer. Fixed by switching to SpecialAssigneeReplacer (which
   handles both @me and @copilot) like issue create already does.

2. The replaceActorsForAssignable mutation requires the [bot] suffix on
   bot actor logins (e.g. `copilot-swe-agent[bot]`), unlike
   requestReviewsByLogin which has a separate botLogins field. Added the
   suffix in ReplaceActorsForAssignableByLogin for CopilotAssigneeLogin.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-24 23:26:28 -06:00
Kynan Ware
ae5e857c2e refactor(featuredetection): rename ActorIsAssignable to ApiActorsSupported
Aligns the feature detector field name with the downstream
ApiActorsSupported flag introduced in the previous commit, so the
signal has one consistent name from detection through to consumption.

Also consolidates leftover TODO tags (actorIsAssignableCleanup,
requestReviewsByLoginCleanup) under the single // TODO ApiActorsSupported
tag so there's exactly one thing to grep for.

Pure rename with no logic changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-24 21:09:04 -06:00
Kynan Ware
3c00ffdade refactor(pr shared): consolidate ActorAssignees and ActorReviewers into ApiActorsSupported
The CLI had two per-entity flags (ActorAssignees on EditableAssignees and
IssueMetadataState, ActorReviewers on IssueMetadataState) threaded through
different layers of the stack to distinguish github.com from GHES. Both
flags were always set from the same source (issueFeatures.ActorIsAssignable)
and never had different values, but they were carried independently on
different structs. This led to a confusing asymmetry where:

- EditableAssignees had ActorAssignees but EditableReviewers had nothing
- The PR edit flow piggybacked on editable.Assignees.ActorAssignees to
  make reviewer mutation decisions, which was misleading
- RepoMetadataInput only had ActorAssignees with no reviewer equivalent

This commit replaces all per-entity flags with a single ApiActorsSupported
bool hoisted to the shared level on Editable, IssueMetadataState, and
RepoMetadataInput. Both assignees and reviewers now key off the same signal.

Every branch site is marked with // TODO ApiActorsSupported so we can grep
for cleanup sites when GHES eventually supports the actor-based mutations
(replaceActorsForAssignable, requestReviewsByLogin).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-24 21:04:41 -06:00
Kynan Ware
11f177a8c3 feat(pr create, issue create): search-based assignee selection in MetadataSurvey
Wire up MultiSelectWithSearch for assignees in MetadataSurvey, replacing
the static MultiSelect that required bulk fetching all assignable actors.
This applies to both gh pr create and gh issue create interactive flows
when selecting assignees via the 'Add metadata' prompt.

Changes:
- Add assigneeSearchFunc parameter to MetadataSurvey
- Skip assignee bulk fetch when search func is available
- New SearchRepoAssignableActors API function for repo-level search
  (create flows have no issue/PR node ID yet)
- New RepoAssigneeSearchFunc in shared editable.go
- Refactor actorsToSearchResult helper shared by both search functions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-23 18:49:28 -06:00
Kynan Ware
e6d9019bc9 fix(pr create): use login-based assignee mutation on github.com
When ActorAssignees is true (github.com), pass assignee logins directly
to the ReplaceActorsForAssignable mutation instead of resolving logins
to node IDs. This eliminates the need to bulk fetch all assignable
users/actors and fixes a bug where providing assignees via CLI flag
and then interactively adding metadata would fail with 'not found'
because the cached MetadataResult had no assignee data.

Changes:
- Set state.ActorAssignees = true in pr create (was missing)
- AddMetadataToIssueParams: pass assigneeLogins when ActorAssignees
  is true, skip fetch and ID resolution entirely
- CreatePullRequest/IssueCreate: call ReplaceActorsForAssignableByLogin
  after creation to assign via logins
- Consolidate replaceActorsForAssignable mutation into api/ package
  (ReplaceActorsForAssignableByLogin + ReplaceActorsForAssignableByID)
- Remove duplicate replaceActorAssigneesForEditable from editable_http.go
- Add TODO replaceActorsByLoginCleanup markers on edit paths

Fixes cli/cli#13000

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-23 15:21:20 -06:00
Kynan Ware
93c4340f29
Merge pull request #12627 from cli/kw/pr-create-multi-select-with-search-ccr
`gh pr create`: login-based reviewer requests and search-based interactive selection
2026-03-06 10:24:19 -07:00
Kynan Ware
08c7a4c207 Replace @copilot with Copilot reviewer login in gh pr create
Wire CopilotReviewerReplacer into NewIssueState so that
`gh pr create --reviewer @copilot` correctly resolves to the
copilot-pull-request-reviewer bot login, matching the behavior
already implemented in gh pr edit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-05 15:15:33 -07:00
William Martin
2b5c3b5ecb document fork default branch behavior 2026-02-13 15:36:37 +01:00
William Martin
7448aed8ab fork default branch only in pr create 2026-02-12 16:56:14 +01:00
Kynan Ware
7373de3e70
Remove redundant comment 2026-02-10 10:58:23 -07:00
Kynan Ware
dd9ab7152b
Don't swallow error from FD
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-10 10:54:03 -07:00
Kynan Ware
620261fea4
Remove redundant comments 2026-02-10 10:53:30 -07:00
Kynan Ware
9904f7d1b9 gh pr create: CCR and multiselectwithsearch 2026-02-04 14:56:05 -07:00
majiayu000
0f4b9b0d91
refactor: address review comments
Signed-off-by: majiayu000 <1835304752@qq.com>
2026-01-21 18:28:21 +08:00
majiayu000
9daa22ebac fix: error when head and base refs are identical in pr create
When a user runs `gh pr create` with head and base refs pointing to
the same ref in the same repository, the command now exits with an
error instead of proceeding with an invalid PR creation.

This prevents accidental pushes to the main branch and provides clear
feedback when users attempt to create a PR from the base branch.

Cross-repository PRs (e.g., from forks) with the same branch name
continue to work as expected.

Fixes #11903

Signed-off-by: majiayu000 <1835304752@qq.com>
2025-12-26 19:14:06 +08:00
Andy Feller
1eeb797975
Revert "Fix: gh pr create prioritize --title and --body over --fill w…"
This reverts commit b31f38c946.
2025-07-14 17:23:09 -04:00
Daniel Krzeminski
b31f38c946
Fix: gh pr create prioritize --title and --body over --fill when --web is present (#10547)
* fix: prioritize title and body over autofill for prs

* fix: prioritize title and body over autofill tests

* refactor: collapse state conditions

---------

Co-authored-by: Babak K. Shandiz <babakks@github.com>
2025-06-24 12:54:43 +00:00
Babak K. Shandiz
59a585de9c
Mention created PR's URL will be printed upon success
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-05-13 14:53:36 +01:00
William Martin
1a5b7ca60c Feature detect v1 projects for preview URL
As far as I can see, when there is project metadata, the preview option
will never be shown in the interactive multiselect, so I don't believe
this change has any functional difference. However, I did use the
opportunity to drive out tests for generateCompareURL
2025-05-02 17:42:23 +02:00
William Martin
5a3aee056a Feature detect v1 projects on interactive pr create 2025-05-02 17:42:23 +02:00
William Martin
9822bb5d07 Feature detect v1 projects on web mode pr create 2025-05-02 15:11:04 +02:00
William Martin
e995a873cb Feature detect v1 projects on non-interactive pr create 2025-05-02 15:08:34 +02:00
William Martin
c208b1f075 Feature detect v1 projects on web mode issue create 2025-04-17 21:04:08 +02:00
William Martin
c8dd61d837 Feature detect v1 projects on non-interactive issue create 2025-04-17 17:51:38 +02:00
William Martin
a9dbda6913 Rework ref usage when finding and creating PRs 2025-04-15 13:38:10 -06:00
Kynan Ware
028caa3823 docs(pr create): clarify BaseRepo type in submitPR 2025-04-15 13:38:10 -06:00
Kynan Ware
339e1a25f3 docs(pr create): add link for user:branch syntax 2025-04-15 13:38:10 -06:00
Kynan Ware
81d00a36f8 fix(pr create): use existing local variables
Co-authored-by: Andy Feller <andyfeller@github.com>
2025-04-15 13:38:10 -06:00
Kynan Ware
15ea861b79 docs(pr create): help text, doc user:branch syntax
Document the user:branch syntax for the `--head`` flag in `gh pr create`.
2025-04-15 13:38:10 -06:00
Kynan Ware
7bb5d71f4c doc(pr create): improve head repo resolution comments
Co-authored-by: Andy Feller <andyfeller@github.com>
2025-04-15 13:38:10 -06:00
Kynan Ware
041f02c980 docs(pr create): standard <user>:<branch> syntax
Standardize <user>:<branch> syntax wherever it is described in comments.
2025-04-15 13:38:10 -06:00
Kynan Ware
e9e57f3ee3 doc(pr create): fix typo in comments
Co-authored-by: Tyler McGoffin <jtmcg@github.com>
2025-04-15 13:38:10 -06:00
Kynan Ware
d524cbddc2 docs(pr create): clarify comment on head branch syntax 2025-04-15 13:38:10 -06:00
Kynan Ware
e999976b3d refactor(pr create): add PullRequestRefs HasHead 2025-04-15 13:38:10 -06:00
Kynan Ware
54da786bec fix(pr create): update error handling 2025-04-15 13:38:10 -06:00
Kynan Ware
911079c744 docs(pr create): add comments 2025-04-15 13:38:10 -06:00
Kynan Ware
cf58910ac0 refactor(pr create): named headRefName var 2025-04-15 13:38:10 -06:00
Kynan Ware
9f1cb0cd54 refactor(pr create): simplify head remote logic 2025-04-15 13:38:10 -06:00
Kynan Ware
f50dac53cb docs(pr create): fix <repo_name>:<branch> desc. 2025-04-15 13:38:10 -06:00
Kynan Ware
c0c5d9123d refactor(pr create): use GetPRHeadLabel()
Use PrRefs.GetPRHeadLabel() instead of headBranchLabel.
Also remove headBranchLabel from CreateContext struct.

To do this, we needed a new identifier for when the head repo should be
created via a new fork of the base repo. Previously, this was done by
checking if the head repo was nil, but if we want to call
GetPRHeadLabel(), it requires a non-nil head repo to construct the
headBranchLabel. So, instead of the head repo being nil to signal
a fork, we pass a new forkHeadRepo bool in the CreateContext struct.
This also makes the decision to fork more intentional; now the decision
is made clearly instead of if the headRepo happens to be nil.
2025-04-15 13:38:10 -06:00
Kynan Ware
178fb40515 refactor(pr create): Use PrRefs in CreateContext
Replace BaseRepo, HeadRepo, HeadBranch with PrRefs in CreateContext struct.
2025-04-15 13:38:10 -06:00
Kynan Ware
c3087cde99 refactor(pr create): Refactor NewCreateContext
- Use prRefs instead of local vars more.
- Rename variables for readability.
- Improve comments.
- Refactor tests.
2025-04-15 13:38:10 -06:00
Kynan Ware
10e3949348 refactor(pr create): use prRefs.GetPRHeadLabel() 2025-04-15 13:38:10 -06:00
Kynan Ware
84a35ca381 refactor: rename IsPushEnabled for clarity 2025-04-15 13:38:10 -06:00
Kynan Ware
dc486258cb test(pr create): test --head=<remote>:<branch> 2025-04-15 13:38:10 -06:00
Kynan Ware
6db9048557 refactor: Refactor pr create
Refactor pr create by reducing flapping `isPushEnabled` between true and false.
`isPushEnabled` is now also set to `true` by default, logically aligning with the
behavior description in the help text.
2025-04-15 13:38:10 -06:00
Kynan Ware
a8d01c70cd feat: support @{push} revision syntax 2025-04-15 13:38:10 -06:00
Andy Feller
918cafc222 Deprecate ColorScheme.Gray for ColorScheme.Muted
This commit converts all of the places using ColorScheme.Gray and ColorScheme.Grayf to Muted and Mutedf.

There is a little extra tidying up with local variable names or converting code to use Mutedf format.
2025-04-06 10:18:48 -04:00
Andy Feller
af99c9d495 Suggestions to enhance upstream default handling
This commit brings this code more into alignment with other places:

1. Using a local variable for upstream remote name instead of hardcoding everywhere
2. Raising error raised by setting default remote
3. Removing condition for displaying upstream default message
4. Bring message logic more inline with other places within function
2025-02-18 16:02:50 -05:00
David Livingston
5004ba2b91 update default upstream when forking repo
update default upstream when forking repo

remove unnecessary variable
2025-02-17 11:14:16 +08:00