internal/build: parse buildbot tag better

This commit is contained in:
Felix Lange 2022-05-20 19:59:26 +02:00
parent c78ea526b8
commit 29685bbe91

View file

@ -97,11 +97,10 @@ func Env() Environment {
// we can distinguish them by the git refspec. // we can distinguish them by the git refspec.
var branch, tag string var branch, tag string
branchSpec := os.Getenv("BUILD_BRANCH") branchSpec := os.Getenv("BUILD_BRANCH")
switch { if strings.HasPrefix(branchSpec, "refs/tags/") {
case strings.HasPrefix(branchSpec, "refs/heads/"):
branch = strings.TrimPrefix(branchSpec, "refs/heads/")
case strings.HasPrefix(branchSpec, "refs/tags/"):
tag = strings.TrimPrefix(branchSpec, "refs/tags/") tag = strings.TrimPrefix(branchSpec, "refs/tags/")
} else {
branch = branchSpec
} }
commit := os.Getenv("BUILD_COMMIT") commit := os.Getenv("BUILD_COMMIT")