diff --git a/config.go b/config.go index ab45475..6c5a1c9 100644 --- a/config.go +++ b/config.go @@ -231,22 +231,30 @@ func parseConfig() { log.Println("VERSION =", version) log.Println("len(VERSION) =", len(version)) - _, ref, _ := shell.Run("cat .git/refs/tags/v" + version) - perl(ref) - ref = strings.TrimSpace(ref) - log.Println("VERSION git ref =", ref) + _, tagref, _ := shell.Run("cat .git/refs/tags/v" + version) + perl(tagref) + tagref = strings.TrimSpace(tagref) + log.Println("VERSION git tag ref =", tagref) _, currentRef, _ := shell.Run("git rev-list -1 HEAD") - log.Println("CURRENT VERSION git ref =", currentRef) - config.Gitref = strings.TrimSuffix(currentRef, "\n") + config.Gitref = chomp(currentRef) _, goversion, _ := shell.Run("go version") - config.Goversion = strings.TrimSuffix(goversion, "\n") + config.Goversion = chomp(goversion) config.Dirty = false - if (ref != currentRef) { + if (tagref == config.Gitref) { + log.Println("setting config.Dirty = false") + config.Dirty = false + } else { + log.Println("setting config.Dirty = true") config.Dirty = true } + + log.Println("tagref =", tagref) + log.Println("config.Gitref =", config.Gitref) + log.Println("config.Goversion =", config.Goversion) + log.Println("config.Dirty =", config.Dirty) } // TODO: fix this to chomp \n \r NULL \t and ' ' @@ -255,10 +263,15 @@ func chomp(s string) string { // var bytesSplice []byte // byteSlice := bytesBuffer.Bytes() // b := bytes.Trim(byteSlice, "\x00") // removes NULL + s = strings.Trim(s, "\x00") + s = strings.Trim(s, "\n") + s = strings.Trim(s, "\n") + s = strings.TrimSuffix(s, "\r") + s = strings.TrimSuffix(s, "\n") - cmd := strings.TrimSpace(s) // this is like 'chomp' in perl - cmd = strings.TrimSuffix(cmd, "\n") // this is like 'chomp' in perl - return cmd + s = strings.TrimSpace(s) // this is like 'chomp' in perl + s = strings.TrimSuffix(s, "\n") // this is like 'chomp' in perl + return s } func perl(a ...interface{}) {