diff options
author | Yondon Fu <yondon.fu@gmail.com> | 2017-12-19 06:17:41 +0800 |
---|---|---|
committer | Yondon Fu <yondon.fu@gmail.com> | 2017-12-19 06:17:41 +0800 |
commit | 3857cdc267e3192697f561df0a0f827f65dfb6b5 (patch) | |
tree | 401c52c4972a68229ea283a394a0b0a5f3cfdc8e /internal/build/env.go | |
parent | a5330fe0c569b75cb8a524f60f7e8dc06498262b (diff) | |
parent | fe070ab5c32702033489f1b9d1655ea1b894c29e (diff) | |
download | dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.gz dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.bz2 dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.lz dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.xz dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.zst dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.zip |
Merge branch 'master' into abi-offset-fixed-arrays
Diffstat (limited to 'internal/build/env.go')
-rw-r--r-- | internal/build/env.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/internal/build/env.go b/internal/build/env.go index c47681ebe..c9848bf82 100644 --- a/internal/build/env.go +++ b/internal/build/env.go @@ -82,18 +82,22 @@ func Env() Environment { // LocalEnv returns build environment metadata gathered from git. func LocalEnv() Environment { env := applyEnvFlags(Environment{Name: "local", Repo: "ethereum/go-ethereum"}) - if _, err := os.Stat(".git"); err != nil { + + head := readGitFile("HEAD") + if splits := strings.Split(head, " "); len(splits) == 2 { + head = splits[1] + } else { return env } if env.Commit == "" { - env.Commit = RunGit("rev-parse", "HEAD") + env.Commit = readGitFile(head) } if env.Branch == "" { - if b := RunGit("rev-parse", "--abbrev-ref", "HEAD"); b != "HEAD" { - env.Branch = b + if head != "HEAD" { + env.Branch = strings.TrimLeft(head, "refs/heads/") } } - if env.Tag == "" { + if info, err := os.Stat(".git/objects"); err == nil && info.IsDir() && env.Tag == "" { env.Tag = firstLine(RunGit("tag", "-l", "--points-at", "HEAD")) } return env |