Forráskód Böngészése

internal/build: use 'git tag --points-at' to get the current tag

This should restore support for building with git 1.x.
Felix Lange 9 éve
szülő
commit
20899c05a4
1 módosított fájl, 6 hozzáadás és 1 törlés
  1. 6 1
      internal/build/env.go

+ 6 - 1
internal/build/env.go

@@ -20,6 +20,7 @@ import (
 	"flag"
 	"fmt"
 	"os"
+	"strings"
 )
 
 var (
@@ -89,11 +90,15 @@ func LocalEnv() Environment {
 		}
 	}
 	if env.Tag == "" {
-		env.Tag = RunGit("for-each-ref", "--points-at=HEAD", "--count=1", "--format=%(refname:short)", "refs/tags")
+		env.Tag = firstLine(RunGit("tag", "-l", "--points-at", "HEAD"))
 	}
 	return env
 }
 
+func firstLine(s string) string {
+	return strings.Split(s, "\n")[0]
+}
+
 func applyEnvFlags(env Environment) Environment {
 	if !flag.Parsed() {
 		panic("you need to call flag.Parse before Env or LocalEnv")