From e401536c97f6c31a10f89952757dbb92cdf60e2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Sun, 12 Nov 2017 22:51:19 +0200 Subject: [PATCH] dockerignore, internal/build: forward correct git folder --- .dockerignore | 6 +++--- internal/build/env.go | 5 +++-- internal/build/util.go | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.dockerignore b/.dockerignore index 751ff2a0c2..d280741c60 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,7 @@ **/.git -/.git -!/.git/HEAD -!/.git/refs/heads +.git +!.git/HEAD +!.git/refs/heads **/*_test.go build/_workspace diff --git a/internal/build/env.go b/internal/build/env.go index 793242fcf0..c9848bf82c 100644 --- a/internal/build/env.go +++ b/internal/build/env.go @@ -82,14 +82,15 @@ func Env() Environment { // LocalEnv returns build environment metadata gathered from git. func LocalEnv() Environment { env := applyEnvFlags(Environment{Name: "local", Repo: "ethereum/go-ethereum"}) - head := ReadGitFile("HEAD") + + head := readGitFile("HEAD") if splits := strings.Split(head, " "); len(splits) == 2 { head = splits[1] } else { return env } if env.Commit == "" { - env.Commit = ReadGitFile(head) + env.Commit = readGitFile(head) } if env.Branch == "" { if head != "HEAD" { diff --git a/internal/build/util.go b/internal/build/util.go index 91465c4199..c6e059f0df 100644 --- a/internal/build/util.go +++ b/internal/build/util.go @@ -89,8 +89,8 @@ func RunGit(args ...string) string { return strings.TrimSpace(stdout.String()) } -// ReadGitFile returns content of file in .git directory. -func ReadGitFile(file string) string { +// readGitFile returns content of file in .git directory. +func readGitFile(file string) string { content, err := ioutil.ReadFile(path.Join(".git", file)) if err != nil { return ""