Skip to content

Commit d90112c

Browse files
Include git commit in version (#1347)
* Include git commit in version Signed-off-by: Tim Vaillancourt <[email protected]> * Make --version output change less-breaking --------- Signed-off-by: Tim Vaillancourt <[email protected]>
1 parent b22229f commit d90112c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,14 @@ main() {
5656
exit 1
5757
fi
5858

59+
if [ -z "${GIT_COMMIT}" ]; then
60+
GIT_COMMIT=$(git rev-parse HEAD)
61+
fi
62+
5963
buildpath=/tmp/gh-ost-release
6064
target=gh-ost
6165
timestamp=$(date "+%Y%m%d%H%M%S")
62-
ldflags="-X main.AppVersion=${RELEASE_VERSION}"
66+
ldflags="-X main.AppVersion=${RELEASE_VERSION} -X main.GitCommit=${GIT_COMMIT}"
6367

6468
mkdir -p ${buildpath}
6569
rm -rf ${buildpath:?}/*

go/cmd/gh-ost/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"golang.org/x/term"
2323
)
2424

25-
var AppVersion string
25+
var AppVersion, GitCommit string
2626

2727
// acceptSignals registers for OS signals
2828
func acceptSignals(migrationContext *base.MigrationContext) {
@@ -165,7 +165,7 @@ func main() {
165165
if appVersion == "" {
166166
appVersion = "unversioned"
167167
}
168-
fmt.Println(appVersion)
168+
fmt.Printf("%s (git commit: %s)", appVersion, GitCommit)
169169
return
170170
}
171171

@@ -308,7 +308,7 @@ func main() {
308308
migrationContext.Log.Errore(err)
309309
}
310310

311-
log.Infof("starting gh-ost %+v", AppVersion)
311+
log.Infof("starting gh-ost %+v (git commit: %s)", AppVersion, GitCommit)
312312
acceptSignals(migrationContext)
313313

314314
migrator := logic.NewMigrator(migrationContext, AppVersion)

0 commit comments

Comments
 (0)