add git version to srnd version string
This commit is contained in:
parent
a85622854b
commit
dee8c005fd
@ -11,7 +11,7 @@ assert-go:
|
|||||||
test $(VERSION) = go1.9
|
test $(VERSION) = go1.9
|
||||||
|
|
||||||
srndv2: assert-go
|
srndv2: assert-go
|
||||||
GOPATH=$(REPO) GOROOT=$(GOROOT) $(GO) build -v
|
GOPATH=$(REPO) GOROOT=$(GOROOT) $(GO) build -ldflags "-X srnd.GitVersion=-$(shell git rev-parse --short HEAD)" -v
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
GOPATH=$(REPO) GOROOT=$(GOROOT) $(GO) clean -v
|
GOPATH=$(REPO) GOROOT=$(GOROOT) $(GO) clean -v
|
||||||
|
@ -6,10 +6,12 @@ package srnd
|
|||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
var major_version = 5
|
const major_version = 5
|
||||||
var minor_version = 0
|
const minor_version = 0
|
||||||
var program_name = "srnd"
|
const program_name = "srnd"
|
||||||
|
|
||||||
|
var GitVersion string
|
||||||
|
|
||||||
func Version() string {
|
func Version() string {
|
||||||
return fmt.Sprintf("%s version 2.%d.%d", program_name, major_version, minor_version)
|
return fmt.Sprintf("%s-2.%d.%d%s", program_name, major_version, minor_version, GitVersion)
|
||||||
}
|
}
|
||||||
|
@ -140,10 +140,12 @@ func main() {
|
|||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(os.Stdout, "Usage: %s tool [rethumb|keygen|nntp|mod|expire]\n", os.Args[0])
|
fmt.Fprintf(os.Stdout, "Usage: %s tool [rethumb|keygen|nntp|mod|expire]\n", os.Args[0])
|
||||||
}
|
}
|
||||||
|
} else if action == "version" {
|
||||||
|
fmt.Println(srnd.Version())
|
||||||
} else {
|
} else {
|
||||||
log.Println("Invalid action:", action)
|
log.Println("Invalid action:", action)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(os.Stdout, "Usage: %s [setup|run|tool]\n", os.Args[0])
|
fmt.Fprintf(os.Stdout, "Usage: %s [setup|run|tool|version]\n", os.Args[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user