forked from cli/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! Only find PRs using branch.<name>.merge if push.default = upst…
…ream
- Loading branch information
1 parent
3693b51
commit b7521e1
Showing
4 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,7 +375,7 @@ Requesting a code review from you | |
} | ||
} | ||
|
||
func Test_prSelectorForCurrentBranch(t *testing.T) { | ||
func Test_prSelectorForCurrentBranchPushDefaultUpstream(t *testing.T) { | ||
rs, cleanup := run.Stub() | ||
defer cleanup(t) | ||
|
||
|
@@ -406,3 +406,35 @@ func Test_prSelectorForCurrentBranch(t *testing.T) { | |
t.Errorf("expected headRef to be \"Frederick888:main\", got %q", headRef) | ||
} | ||
} | ||
|
||
func Test_prSelectorForCurrentBranchPushDefaultTracking(t *testing.T) { | ||
rs, cleanup := run.Stub() | ||
defer cleanup(t) | ||
|
||
rs.Register(`git config --get-regexp \^branch\\.`, 0, heredoc.Doc(` | ||
branch.Frederick888/main.remote [email protected]:Frederick888/playground.git | ||
branch.Frederick888/main.merge refs/heads/main | ||
`)) | ||
rs.Register(`git config remote.pushDefault`, 1, "") | ||
rs.Register(`git rev-parse --verify --quiet --abbrev-ref Frederick888/main@\{push\}`, 1, "") | ||
rs.Register(`git config push\.default`, 0, "tracking") | ||
|
||
repo := ghrepo.NewWithHost("octocat", "playground", "github.com") | ||
rem := context.Remotes{ | ||
&context.Remote{ | ||
Remote: &git.Remote{Name: "origin"}, | ||
Repo: repo, | ||
}, | ||
} | ||
gitClient := &git.Client{GitPath: "some/path/git"} | ||
prNum, headRef, err := prSelectorForCurrentBranch(gitClient, repo, "Frederick888/main", rem) | ||
if err != nil { | ||
t.Fatalf("prSelectorForCurrentBranch error: %v", err) | ||
} | ||
if prNum != 0 { | ||
t.Errorf("expected prNum to be 0, got %q", prNum) | ||
} | ||
if headRef != "Frederick888:main" { | ||
t.Errorf("expected headRef to be \"Frederick888:main\", got %q", headRef) | ||
} | ||
} |