From 17a6f3dc8926969fe0b1305e491c92d836da5d07 Mon Sep 17 00:00:00 2001 From: David Paz Date: Mon, 19 Jun 2017 11:20:24 +0200 Subject: [PATCH] Changed commit ref to .git/HEAD --- internal/code-generator/main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/code-generator/main.go b/internal/code-generator/main.go index d1c9f043..1f260910 100644 --- a/internal/code-generator/main.go +++ b/internal/code-generator/main.go @@ -62,7 +62,7 @@ const ( frequenciesTmplPath = "internal/code-generator/assets/frequencies.go.tmpl" frequenciesTmpl = "frequencies.go.tmpl" - commitPath = ".linguist/.git/refs/heads/master" + commitPath = ".linguist/.git/HEAD" ) type generatorFiles struct { @@ -106,5 +106,15 @@ func getCommit(path string) (string, error) { return "", err } + if string(commit) == "ref: refs/heads/master\n" { + path = ".linguist/.git/" + string(commit[5:len(commit)-1]) + commit, err := ioutil.ReadFile(path) + if err != nil { + return "", err + } + + return string(commit), nil + } + return string(commit), nil }