mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 11:01:25 +01:00
fix(pr): keep targeting the base repository after a fork PR checkout
Repository discovery preferred the current branch's upstream remote, which for a fork pull request is the pulls/<owner>/<repo> remote that pr checkout adds, so every later command targeted the fork. pr checkout now records the pull request number and base remote in branch.<name>.tea-pr and branch.<name>.tea-base-remote, discovery honors the recorded base remote, and it skips pulls/* head remotes. Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
5 files changed
+50
-7
No files matched your search
@@ -71,6 +71,7 @@ func TestCheckoutMatchesRemoteThroughEnvironmentSSHHost(t *testing.T) {
|
||||
"status --porcelain=v1 --untracked-files=normal": "", "for-each-ref --format=%(refname) refs/heads/": "",
|
||||
"fetch --no-tags -- origin refs/heads/feature": "", "rev-parse --verify FETCH_HEAD^{commit}": "abc123", "switch --create pr/7 abc123": "",
|
||||
"config branch.pr/7.remote origin": "", "config branch.pr/7.merge refs/heads/feature": "",
|
||||
"config branch.pr/7.tea-pr 7": "", "config branch.pr/7.tea-base-remote origin": "",
|
||||
}}
|
||||
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "checkout", "7", "--repo", "alice/project", "--remote", "origin", "--no-input", "--json"}))
|
||||
require.JSONEq(t, `{"branch":"pr/7","commit":"abc123","detached":false,"remote":"origin","tracking":"origin/feature"}`, out.String())
|
||||
@@ -97,6 +98,7 @@ func TestSSHCheckoutUsesAccountKeyOnlyForFetch(t *testing.T) {
|
||||
"status --porcelain=v1 --untracked-files=normal": "", "for-each-ref --format=%(refname) refs/heads/": "",
|
||||
fetch: "", "rev-parse --verify FETCH_HEAD^{commit}": "abc123", "switch --create pr/7 abc123": "",
|
||||
"config branch.pr/7.remote origin": "", "config branch.pr/7.merge refs/heads/feature": "",
|
||||
"config branch.pr/7.tea-pr 7": "", "config branch.pr/7.tea-base-remote origin": "",
|
||||
}}
|
||||
deps.Git = runner
|
||||
require.NoError(t, Execute(context.Background(), deps, []string{"pr", "checkout", "7", "--repo", "alice/project", "--remote", "origin", "--no-input", "--json"}))
|
||||
|
||||
Reference in new issue
Block a user