fix 'dirty' logic
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
9b27b2915a
commit
adfb25186b
35
config.go
35
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{}) {
|
||||
|
|
Loading…
Reference in New Issue