[TESTS] testPullCreate do not assume the default branch is master
This commit is contained in:
parent
d3d0c4cbe7
commit
19d7ff9c9e
1 changed files with 8 additions and 5 deletions
|
@ -10,6 +10,7 @@ import (
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"net/url"
|
"net/url"
|
||||||
"path"
|
"path"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -42,14 +43,16 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo string, toSel
|
||||||
link = strings.Replace(link, targetUser, user, 1)
|
link = strings.Replace(link, targetUser, user, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if targetBranch != "master" {
|
// get main out of /user/project/main...some:other/branch
|
||||||
link = strings.Replace(link, "master...", targetBranch+"...", 1)
|
defaultBranch := regexp.MustCompile(`^.*/(.*)\.\.\.`).FindStringSubmatch(link)[1]
|
||||||
|
if targetBranch != defaultBranch {
|
||||||
|
link = strings.Replace(link, defaultBranch+"...", targetBranch+"...", 1)
|
||||||
}
|
}
|
||||||
if sourceBranch != "master" {
|
if sourceBranch != defaultBranch {
|
||||||
if targetUser == user {
|
if targetUser == user {
|
||||||
link = strings.Replace(link, "...master", "..."+sourceBranch, 1)
|
link = strings.Replace(link, "..."+defaultBranch, "..."+sourceBranch, 1)
|
||||||
} else {
|
} else {
|
||||||
link = strings.Replace(link, ":master", ":"+sourceBranch, 1)
|
link = strings.Replace(link, ":"+defaultBranch, ":"+sourceBranch, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue