Add test for empty BranchConfig in prSelectorForCurrentBranch
This commit is contained in:
parent
15ac566222
commit
d4f7576e8b
2 changed files with 11 additions and 2 deletions
|
|
@ -214,8 +214,8 @@ func prSelectorForCurrentBranch(branchConfig git.BranchConfig, baseRepo ghrepo.I
|
|||
branchOwner = r.RepoOwner()
|
||||
}
|
||||
|
||||
selector := prHeadRef
|
||||
if branchOwner != "" {
|
||||
selector := prHeadRef
|
||||
if strings.HasPrefix(branchConfig.MergeRef, "refs/heads/") {
|
||||
selector = strings.TrimPrefix(branchConfig.MergeRef, "refs/heads/")
|
||||
}
|
||||
|
|
@ -223,9 +223,10 @@ func prSelectorForCurrentBranch(branchConfig git.BranchConfig, baseRepo ghrepo.I
|
|||
if !strings.EqualFold(branchOwner, baseRepo.RepoOwner()) {
|
||||
selector = fmt.Sprintf("%s:%s", branchOwner, selector)
|
||||
}
|
||||
return 0, selector, nil
|
||||
}
|
||||
|
||||
return 0, selector, nil
|
||||
return 0, prHeadRef, nil
|
||||
}
|
||||
|
||||
func totalApprovals(pr *api.PullRequest) int {
|
||||
|
|
|
|||
|
|
@ -387,6 +387,14 @@ func Test_prSelectorForCurrentBranch(t *testing.T) {
|
|||
wantSelector string
|
||||
wantError error
|
||||
}{
|
||||
{
|
||||
name: "Empty branch config",
|
||||
branchConfig: git.BranchConfig{},
|
||||
prHeadRef: "Frederick888/main",
|
||||
wantPrNumber: 0,
|
||||
wantSelector: "Frederick888/main",
|
||||
wantError: nil,
|
||||
},
|
||||
{
|
||||
name: "The branch is configured to merge a special PR head ref",
|
||||
branchConfig: git.BranchConfig{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue