Commit 20899c05 authored by Felix Lange's avatar Felix Lange

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

This should restore support for building with git 1.x.
parent 4c8c5e2f
...@@ -20,6 +20,7 @@ import ( ...@@ -20,6 +20,7 @@ import (
"flag" "flag"
"fmt" "fmt"
"os" "os"
"strings"
) )
var ( var (
...@@ -89,11 +90,15 @@ func LocalEnv() Environment { ...@@ -89,11 +90,15 @@ func LocalEnv() Environment {
} }
} }
if env.Tag == "" { 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 return env
} }
func firstLine(s string) string {
return strings.Split(s, "\n")[0]
}
func applyEnvFlags(env Environment) Environment { func applyEnvFlags(env Environment) Environment {
if !flag.Parsed() { if !flag.Parsed() {
panic("you need to call flag.Parse before Env or LocalEnv") panic("you need to call flag.Parse before Env or LocalEnv")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment