Skip to content

Commit dc46313

Browse files
committed
[enh] display the build commit id in the version string - closes asciimoo#294
1 parent 1adc542 commit dc46313

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

hister.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"os"
1717
"path/filepath"
1818
"runtime"
19+
"runtime/debug"
1920
"strconv"
2021
"strings"
2122
"time"
@@ -41,7 +42,18 @@ import (
4142
"gopkg.in/yaml.v3"
4243
)
4344

44-
const Version = "v0.11.0"
45+
const versionBase = "v0.11.0"
46+
47+
var Version = func() string {
48+
if info, ok := debug.ReadBuildInfo(); ok {
49+
for _, s := range info.Settings {
50+
if s.Key == "vcs.revision" && len(s.Value) >= 7 {
51+
return fmt.Sprintf("%s (%s)", versionBase, s.Value[:7])
52+
}
53+
}
54+
}
55+
return versionBase
56+
}()
4557

4658
var (
4759
cliErrorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("9")).Bold(true)
@@ -72,7 +84,7 @@ var (
7284
var rootCmd = &cobra.Command{
7385
Use: "hister",
7486
Short: "Your own search engine",
75-
Long: "hister - your own search engine",
87+
Long: "Hister - your own search engine",
7688
Version: Version,
7789
//Run: func(_ *cobra.Command, _ []string) {
7890
//},

0 commit comments

Comments
 (0)