Allowing to specify different branch in first parameter

This commit is contained in:
David Vennik
2022-12-21 14:50:51 +00:00
parent 7d05f18e93
commit c242b8f234
2 changed files with 13 additions and 9 deletions

View File

@@ -129,11 +129,12 @@ func main() {
); check(e) {
return
}
startArgs := 1
br := strings.Split(GitRef, "/")
branch := br[len(br)-1]
startArgs := 1
branchParam := os.Args[1]
if major || minor {
branch = os.Args[2]
branchParam = os.Args[2]
}
var out string
if out, e = runCmdWithOutput("git", "branch"); check(e) {
@@ -145,17 +146,22 @@ func main() {
if len(splitted[i]) < 2 {
continue
}
if splitted[i][2:] == branch {
if splitted[i][2:] == branchParam {
isBranch = true
branch = splitted[i][2:]
break
}
}
log.I.S(isBranch, branch)
if isBranch {
branch = branchParam
}
if isBranch {
startArgs++
}
tag := true
if branch == "main" {
if branch != "main" {
tag = false
} else {
switch {
case minor:
Minor++
@@ -167,8 +173,6 @@ func main() {
default:
Patch++
}
} else {
tag = false
}
SemVer = fmt.Sprintf("v%d.%d.%d", Major, Minor, Patch)
PathBase = tr.Filesystem.Root() + "/"

View File

@@ -13,9 +13,9 @@ var (
// GitRef is the gitref, as in refs/heads/branchname.
GitRef = "refs/heads/main"
// ParentGitCommit is the commit hash of the parent HEAD.
ParentGitCommit = "11ff201d7096d1e1dd9c3e82b68cfc9dd22cb73e"
ParentGitCommit = "5c72c2dabc3e5af39689ee4c9e0d0057c31de54c"
// BuildTime stores the time when the current binary was built.
BuildTime = "2022-12-21T14:41:05Z"
BuildTime = "2022-12-21T14:50:51Z"
// SemVer lists the (latest) git tag on the build.
SemVer = "v0.0.208"
// PathBase is the path base returned from runtime caller.