Skip to content

Commit edd7df0

Browse files
committed
simplify getBranchGitLab
1 parent 4b0953f commit edd7df0

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

internal/gitsemver/gitsemver.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,21 +180,19 @@ func (vs *GitSemVer) getBranchGitHub(repo string) (branchName string, err error)
180180
}
181181

182182
func (vs *GitSemVer) getBranchGitLab(repo string) (branchName string, err error) {
183-
if branchName = strings.TrimSpace(vs.Env.Getenv("CI_COMMIT_REF_NAME")); branchName == "" {
184-
return
185-
}
186-
if strings.TrimSpace(vs.Env.Getenv("CI_COMMIT_TAG")) != branchName {
187-
return branchName, nil
188-
}
189-
var branches []string
190-
if branches, err = vs.Git.GetBranchesFromTag(repo, branchName); err == nil {
191-
for _, candidate := range branches {
192-
if vs.IsReleaseBranch(candidate) {
193-
return candidate, nil
183+
if branchName = strings.TrimSpace(vs.Env.Getenv("CI_COMMIT_REF_NAME")); branchName != "" {
184+
if strings.TrimSpace(vs.Env.Getenv("CI_COMMIT_TAG")) == branchName {
185+
var branches []string
186+
if branches, err = vs.Git.GetBranchesFromTag(repo, branchName); err == nil {
187+
for _, branchName = range branches {
188+
if vs.IsReleaseBranch(branchName) {
189+
return
190+
}
191+
}
194192
}
193+
branchName = ""
195194
}
196195
}
197-
branchName = ""
198196
return
199197
}
200198

0 commit comments

Comments
 (0)