diff --git a/templates/footer.tmpl b/templates/footer.tmpl index 7c6b31d..cd6900a 100644 --- a/templates/footer.tmpl +++ b/templates/footer.tmpl @@ -1,6 +1,8 @@ {{ define "footer" }} {{ end }} diff --git a/templates/template.go b/templates/template.go index b75289c..8355d96 100644 --- a/templates/template.go +++ b/templates/template.go @@ -27,6 +27,7 @@ func New() *Template { "IsScriptInNotes": util.IsScriptInNotes, "ValueToBigInt": types.ValueToBigInt, "TimeDisclaimer": util.TimeDisclaimer, + "GitCommit": util.GitCommit, } templates := template.Must(template.New("").Funcs(funcMap).ParseFS(Templates, "footer.tmpl", "header.tmpl", "base.tmpl", "note.tmpl")) diff --git a/util/util.go b/util/util.go index 969e833..a7e3cb1 100644 --- a/util/util.go +++ b/util/util.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "html/template" + "runtime/debug" "time" "github.com/RaghavSood/btcsupply/notes" @@ -74,3 +75,17 @@ func TimeDisclaimer(target time.Time) string { } return "" } + +func GitCommit() string { + buildInfo, ok := debug.ReadBuildInfo() + if ok { + settings := buildInfo.Settings + for _, s := range settings { + if s.Key == "vcs.revision" { + return s.Value + } + } + } + + return "unknown" +}