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>
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>
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.
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.
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.
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.
* 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>
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
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.