File tree 3 files changed +18
-3
lines changed
3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change
1
+ /yb-voyager /src /utils /version.go export-subst
Original file line number Diff line number Diff line change @@ -14,14 +14,17 @@ var versionCmd = &cobra.Command{
14
14
15
15
Run : func (cmd * cobra.Command , args []string ) {
16
16
fmt .Printf ("VERSION=%s\n " , utils .YB_VOYAGER_VERSION )
17
-
17
+ h := utils .GitCommitHash ()
18
+ if h != "" {
19
+ fmt .Printf ("GIT_COMMIT_HASH=%s\n " , h )
20
+ }
18
21
info , ok := debug .ReadBuildInfo ()
19
22
if ! ok {
20
23
return
21
24
}
22
25
for _ , setting := range info .Settings {
23
26
if setting .Key == "vcs.revision" {
24
- fmt .Printf ("GIT_HASH =%s\n " , setting .Value )
27
+ fmt .Printf ("GIT_COMMIT_HASH =%s\n " , setting .Value )
25
28
}
26
29
if setting .Key == "vcs.time" {
27
30
fmt .Printf ("LAST_COMMIT_DATE=%s\n " , setting .Value )
Original file line number Diff line number Diff line change @@ -2,5 +2,16 @@ package utils
2
2
3
3
const (
4
4
// This constant must be updated on every release.
5
- YB_VOYAGER_VERSION = "v1.0.0-beta.0"
5
+ YB_VOYAGER_VERSION = "main"
6
+
7
+ // @Refer: https://icinga.com/blog/2022/05/25/embedding-git-commit-information-in-go-binaries/
8
+ GIT_COMMIT_HASH = "$Format:%H$"
6
9
)
10
+
11
+ func GitCommitHash () string {
12
+ if len (GIT_COMMIT_HASH ) == 40 {
13
+ // Substitution has happened.
14
+ return GIT_COMMIT_HASH
15
+ }
16
+ return ""
17
+ }
You can’t perform that action at this time.
0 commit comments