Commit graph

261 commits

Author SHA1 Message Date
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
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