Skip to content

gh pr create: Support Git's @{push} revision syntax for determining head ref#10513

Merged
BagToad merged 40 commits into
trunkfrom
kw/575-detect-push-target-for-local-branches-without-upstream-configuration
Apr 15, 2025
Merged

gh pr create: Support Git's @{push} revision syntax for determining head ref#10513
BagToad merged 40 commits into
trunkfrom
kw/575-detect-push-target-for-local-branches-without-upstream-configuration

Conversation

@BagToad
Copy link
Copy Markdown
Member

@BagToad BagToad commented Feb 27, 2025

Fixes #575

Description

This adds support Git's @{push} revision syntax for determining head ref.

Acceptance Criteria

Given git rev-parse --abbrev-ref @{push} resolves
when I run gh pr create
then I should create a pr with the headRef pointing at the @[push} return value

Given the branch.<branchName>.pushremote key is set on my current branch
when I run gh pr create
then I should create a pr with the headRef pointing at the remote value in the branch.<branchName>.pushremote key and the current branch name

Given the remote.pushDefault key is set on my current repo
when I run gh pr create
then I should create a pr with the headRef pointing at the remote value in the remote.pushDefault key and the current branch name

Given git rev-parse --abbrev-ref @{push} resolves
and/or given the branch.<branchName>.pushremote key is set on my current branch
and/or given the remote.pushDefault key is set on my current repo
when I run gh pr create
then I should create a pr with the headRef pointing at the given values in the following priority order: @[push} -> branch.<branchName>.pushremote -> remote.pushDefault

Acceptance Tests

--- PASS: TestPullRequests (0.01s)
    --- PASS: TestPullRequests/pr-create-basic (8.67s)
    --- PASS: TestPullRequests/pr-checkout-by-number (8.80s)
    --- PASS: TestPullRequests/pr-create-from-manual-merge-base (8.90s)
    --- PASS: TestPullRequests/pr-checkout (8.93s)
    --- PASS: TestPullRequests/pr-comment (9.26s)
    --- PASS: TestPullRequests/pr-create-with-metadata (9.66s)
    --- PASS: TestPullRequests/pr-view-same-org-fork (11.64s)
    --- PASS: TestPullRequests/pr-create-from-issue-develop-base (11.97s)
    --- PASS: TestPullRequests/pr-view-outside-repo (6.51s)
    --- PASS: TestPullRequests/pr-create-respects-remote-colon-branch-syntax (15.72s)
    --- PASS: TestPullRequests/pr-list (7.05s)
    --- PASS: TestPullRequests/pr-view-status-respects-remote-pushdefault (17.42s)
    --- PASS: TestPullRequests/pr-view-status-respects-push-destination (8.35s)
    --- PASS: TestPullRequests/pr-view (6.52s)
    --- PASS: TestPullRequests/pr-merge-rebase-strategy (9.83s)
    --- PASS: TestPullRequests/pr-merge-merge-strategy (9.97s)
    --- PASS: TestPullRequests/pr-checkout-with-url-from-fork (12.15s)
    --- PASS: TestPullRequests/pr-view-status-respects-simple-pushdefault (8.59s)
    --- PASS: TestPullRequests/pr-create-without-upstream-config (6.96s)
    --- PASS: TestPullRequests/pr-create-respects-simple-pushdefault (7.51s)
    --- PASS: TestPullRequests/pr-create-respects-push-destination (15.02s)
    --- PASS: TestPullRequests/pr-create-respects-branch-pushremote (14.77s)
    --- PASS: TestPullRequests/pr-view-status-respects-branch-pushremote (16.00s)
    --- PASS: TestPullRequests/pr-create-respects-remote-pushdefault (15.02s)
PASS
ok      github.com/cli/cli/v2/acceptance        34.077s

Notes

A lot of review for this PR happened on #10621

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect push target for local branches without upstream configuration

7 participants