Merge pull request #15464 from karalabe/docker-fix

dockerignore, internal/build: forward correct git folder
This commit is contained in:
Péter Szilágyi 2017-11-12 22:56:38 +02:00 committed by GitHub
commit 836314c055
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 7 deletions

View File

@ -1,7 +1,7 @@
**/.git **/.git
/.git .git
!/.git/HEAD !.git/HEAD
!/.git/refs/heads !.git/refs/heads
**/*_test.go **/*_test.go
build/_workspace build/_workspace

View File

@ -82,14 +82,15 @@ func Env() Environment {
// LocalEnv returns build environment metadata gathered from git. // LocalEnv returns build environment metadata gathered from git.
func LocalEnv() Environment { func LocalEnv() Environment {
env := applyEnvFlags(Environment{Name: "local", Repo: "ethereum/go-ethereum"}) env := applyEnvFlags(Environment{Name: "local", Repo: "ethereum/go-ethereum"})
head := ReadGitFile("HEAD")
head := readGitFile("HEAD")
if splits := strings.Split(head, " "); len(splits) == 2 { if splits := strings.Split(head, " "); len(splits) == 2 {
head = splits[1] head = splits[1]
} else { } else {
return env return env
} }
if env.Commit == "" { if env.Commit == "" {
env.Commit = ReadGitFile(head) env.Commit = readGitFile(head)
} }
if env.Branch == "" { if env.Branch == "" {
if head != "HEAD" { if head != "HEAD" {

View File

@ -89,8 +89,8 @@ func RunGit(args ...string) string {
return strings.TrimSpace(stdout.String()) return strings.TrimSpace(stdout.String())
} }
// ReadGitFile returns content of file in .git directory. // readGitFile returns content of file in .git directory.
func ReadGitFile(file string) string { func readGitFile(file string) string {
content, err := ioutil.ReadFile(path.Join(".git", file)) content, err := ioutil.ReadFile(path.Join(".git", file))
if err != nil { if err != nil {
return "" return ""