X Tutup
Skip to content

Commit be75978

Browse files
committed
Fix "Continue in browser" for pr create coming from forks
Ensures that the `owner:` prefix is present when referencing the head branch
1 parent df2ca9c commit be75978

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

pkg/cmd/pr/create/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ func generateCompareURL(ctx CreateContext, state shared.IssueMetadataState) (str
684684
u := ghrepo.GenerateRepoURL(
685685
ctx.BaseRepo,
686686
"compare/%s...%s?expand=1",
687-
url.QueryEscape(ctx.BaseBranch), url.QueryEscape(ctx.HeadBranch))
687+
url.QueryEscape(ctx.BaseBranch), url.QueryEscape(ctx.HeadBranchLabel))
688688
url, err := shared.WithPrAndIssueQueryParams(u, state)
689689
if err != nil {
690690
return "", err

pkg/cmd/pr/create/create_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -827,19 +827,19 @@ func Test_generateCompareURL(t *testing.T) {
827827
{
828828
name: "basic",
829829
ctx: CreateContext{
830-
BaseRepo: ghrepo.New("OWNER", "REPO"),
831-
BaseBranch: "main",
832-
HeadBranch: "feature",
830+
BaseRepo: ghrepo.New("OWNER", "REPO"),
831+
BaseBranch: "main",
832+
HeadBranchLabel: "feature",
833833
},
834834
want: "https://github.com/OWNER/REPO/compare/main...feature?expand=1",
835835
wantErr: false,
836836
},
837837
{
838838
name: "with labels",
839839
ctx: CreateContext{
840-
BaseRepo: ghrepo.New("OWNER", "REPO"),
841-
BaseBranch: "a",
842-
HeadBranch: "b",
840+
BaseRepo: ghrepo.New("OWNER", "REPO"),
841+
BaseBranch: "a",
842+
HeadBranchLabel: "b",
843843
},
844844
state: prShared.IssueMetadataState{
845845
Labels: []string{"one", "two three"},
@@ -850,9 +850,9 @@ func Test_generateCompareURL(t *testing.T) {
850850
{
851851
name: "complex branch names",
852852
ctx: CreateContext{
853-
BaseRepo: ghrepo.New("OWNER", "REPO"),
854-
BaseBranch: "main/trunk",
855-
HeadBranch: "owner:feature",
853+
BaseRepo: ghrepo.New("OWNER", "REPO"),
854+
BaseBranch: "main/trunk",
855+
HeadBranchLabel: "owner:feature",
856856
},
857857
want: "https://github.com/OWNER/REPO/compare/main%2Ftrunk...owner%3Afeature?expand=1",
858858
wantErr: false,

0 commit comments

Comments
 (0)
X Tutup