diff --git a/Makefile b/Makefile index e43c645..1c2ec13 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ -BUILD=go build -o dumber -MV=mv dumber ~/go/bin/dumber -VERSION=`grep -Po '\d*\.\d*\.\d*' main.go` +COMMIT_SHORT_SHA := $(shell git rev-parse --short HEAD) +BUILD=go build -o dumber -ldflags "-X 'main.commitShortHash=$(COMMIT_SHORT_SHA)'" +MV=sudo mv dumber ~/go/bin/dumber help: @echo "Usage:" diff --git a/go.mod b/go.mod index d9a0007..26e4718 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/MichelBoucey/dumber -go 1.22.0 +go 1.22.4 diff --git a/main.go b/main.go index 22dcaf9..f739453 100644 --- a/main.go +++ b/main.go @@ -37,6 +37,10 @@ import ( "strings" ) +var ( + commitShortHash = "" +) + func main() { version := "2.1.0" @@ -69,7 +73,7 @@ func main() { flag.Parse() if *versionFlag == true { - fmt.Println("dumber v" + version + newLine + "Copyright © 2021-2023 Michel Boucey" + newLine + "Released under 3-Clause BSD License") + fmt.Println("dumber v" + version + " (" + commitShortHash + ")" + newLine + "Copyright © 2021-2024 Michel Boucey" + newLine + "Released under 3-Clause BSD License") os.Exit(-1) }