Commit graph

266 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
1d730951d2 Use org/slug format in test fixtures and remove /slug normalization 2026-02-11 14:51:12 -07:00
Kynan Ware
1cb776384e Normalize /slug team shorthand to org/slug and fix docs 2026-02-11 14:33:13 -07:00
Kynan Ware
38661646ee Update test assertions to expect org/slug team format 2026-02-11 13:18:07 -07: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
bbc3d02cb3 Refactor tab completion test
This commit moves the `gh pr create` tab completion test closer to the logic rather than the commands that use it.

This should ensure that any command or flag that lists reviewers will present teams and users as expected.
2025-07-30 09:25:33 -04:00
Andy Feller
c9bc185209 Test gh pr create --reviewer tab completion 2025-07-30 09:16:44 -04:00
Andy Feller
8f20f0ab53 Include org teams for PR reviewers
This commit enhances the following scenarios to include organization teams as pull request reviewers:

1. Interactive `gh pr create` during additional metadata
2. Tab completing `gh pr create --reviewer`
3. Tab completing `gh pr edit --add-reviewer`
4. Tab completing `gh pr edit --remove-reviewer`

Additionally, a new `gh pr create` test case for ensuring that teams show up within interactive prompts has been added.
2025-07-29 18:19:22 -04:00
Kynan Ware
5a6cac3643 Add tests for reviewer team handling in PR creation
Added test cases to verify that teams are fetched when reviewers include teams and not fetched when only users are specified. This ensures correct behavior when requesting reviews from users and teams during pull request creation.
2025-07-23 10:15:30 -06:00
Kynan Ware
df317d4a05 FIX: conditionally fetching team reviewers
Updated the logic for fetching team reviewers in PR edit and create flows. In `pr edit`, team reviewers are always fetched for consistency with existing behavior, with a note to potentially align with `pr create` logic in the future. In `pr create`, team reviewers are now only fetched if a reviewer contains a slash, aligning with behavior before the regression.
2025-07-22 11:00:47 -06:00
Andy Feller
260519dc69
Merge pull request #11279 from cli/andyfeller/issue-create-assign-copilot
Assign Copilot during `gh issue create`
2025-07-16 17:01:32 -04: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
Andy Feller
fd1c31de59 Fix gh pr create tests from metadata change
These are the minimum fixes necessary to repair `gh pr create` tests after refactoring the underlying metadata resolution logic.
2025-07-11 15:32:17 -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
bf7bf99f54 fix(pr create & stubs): handle exitcode in stubs 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
bab7dc650b test(pr create): update repo owner names in tests 2025-04-15 13:38:10 -06:00
Kynan Ware
da235b134b tests(pr create): remove irrelevant comments 2025-04-15 13:38:10 -06:00
Kynan Ware
9b96e6cded doc(pr create): fix typo in test comments
Co-authored-by: Tyler McGoffin <jtmcg@github.com>
2025-04-15 13:38:10 -06:00
Kynan Ware
911079c744 docs(pr create): add comments 2025-04-15 13:38:10 -06:00