Inject git version when building a release

This commit is contained in:
Dan Sosedoff
2015-04-30 20:40:06 -05:00
parent 4224b3d326
commit ca894c621f
2 changed files with 20 additions and 3 deletions

16
main.go
View File

@@ -16,6 +16,9 @@ import (
const VERSION = "0.5.2"
// The git commit that was compiled. This will be filled in by the compiler.
var GitCommit string
var options command.Options
func exitWithMessage(message string) {
@@ -61,11 +64,20 @@ func initOptions() {
options = command.Opts
if options.Version {
fmt.Printf("pgweb v%s\n", VERSION)
printVersion()
os.Exit(0)
}
fmt.Println("Pgweb version", VERSION)
printVersion()
}
func printVersion() {
str := fmt.Sprintf("Pgweb v%s", VERSION)
if GitCommit != "" {
str += fmt.Sprintf(" (git: %s)", GitCommit)
}
fmt.Println(str)
}
func startServer() {