From 19d7ff9c9e17bdcc137b1855040e6955a9c0c949 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Wed, 20 Mar 2024 06:07:02 +0100 Subject: [PATCH] [TESTS] testPullCreate do not assume the default branch is master --- tests/integration/pull_create_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/integration/pull_create_test.go b/tests/integration/pull_create_test.go index cca0a2e68..338305d95 100644 --- a/tests/integration/pull_create_test.go +++ b/tests/integration/pull_create_test.go @@ -10,6 +10,7 @@ import ( "net/http/httptest" "net/url" "path" + "regexp" "strings" "testing" @@ -42,14 +43,16 @@ func testPullCreate(t *testing.T, session *TestSession, user, repo string, toSel link = strings.Replace(link, targetUser, user, 1) } - if targetBranch != "master" { - link = strings.Replace(link, "master...", targetBranch+"...", 1) + // get main out of /user/project/main...some:other/branch + 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 { - link = strings.Replace(link, "...master", "..."+sourceBranch, 1) + link = strings.Replace(link, "..."+defaultBranch, "..."+sourceBranch, 1) } else { - link = strings.Replace(link, ":master", ":"+sourceBranch, 1) + link = strings.Replace(link, ":"+defaultBranch, ":"+sourceBranch, 1) } }