Skip to content

Commit ba7e2d8

Browse files
committed
output git hash in --version
have to do the indirection because setting -X variables in the internal package doesn't seem to work
1 parent bcd8f84 commit ba7e2d8

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ s3proxy.jar:
66

77
get-deps: s3proxy.jar
88
go get -t ./...
9+
10+
build:
11+
go build -ldflags "-X main.Version=`git rev-parse HEAD`"

internal/flags.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,14 @@ COPYRIGHT:
6969
`
7070
}
7171

72+
var VersionHash string
73+
7274
func NewApp() (app *cli.App) {
7375
uid, gid := MyUserAndGroup()
7476

7577
app = &cli.App{
7678
Name: "goofys",
77-
Version: "0.0.12",
79+
Version: "0.0.12-" + VersionHash,
7880
Usage: "Mount an S3 bucket locally",
7981
HideHelp: true,
8082
Writer: os.Stderr,

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ func massageArg0() {
170170
}
171171
}
172172

173+
var Version string
174+
173175
func main() {
176+
VersionHash = Version
177+
174178
app := NewApp()
175179

176180
var flags *FlagStorage

0 commit comments

Comments
 (0)