Fix tag fetching in build-version.go
@@ -12,13 +12,15 @@ func getTag(match ...string) (string, *semver.PRVersion) {
args := append([]string{
"describe", "--tags",
}, match...)
- if tag, err := exec.Command("git", args...).Output(); err != nil {
- return "", nil
- } else {
- if len(tag) == 0 {
+ var tag []byte
+ var err error
+ if tag, err = exec.Command("git", args...).Output(); err != nil {
if _, err := exec.Command("git", "fetch", "tags").Output(); err != nil {
return "", nil
}
+ if tag, err = exec.Command("git", args...).Output(); err != nil {
+ return "", nil
+ }
}
tagParts := strings.Split(string(tag), "-")
if len(tagParts) == 3 {
@@ -33,7 +35,6 @@ func getTag(match ...string) (string, *semver.PRVersion) {
return string(tag), nil
}
-}
func main() {
// Find the last vX.X.X Tag and get how many builds we are ahead of it.
