Skip to content

Commit

Permalink
footer: show git revision
Browse files Browse the repository at this point in the history
  • Loading branch information
RaghavSood committed Jun 7, 2024
1 parent 1f275f3 commit 57be149
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion templates/footer.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{{ define "footer" }}
<footer class="bg-gray-700 mt-8 p-4 text-center mt-auto">
<p>Built by <a href="https://raghavsood.com" target="_blank" class="hover:underline hover:text-slate-200 hover:decoration-dotted text-sky-400/70">Raghav Sood</a>.</p><p>burned.money is licensed under <span class="inline-flex"><a href="https://creativecommons.org/licenses/by/4.0/" target="_blank" rel="license noopener noreferrer" class="hover:underline hover:text-slate-200 hover:decoration-dotted text-sky-400/70">CC BY 4.0</a>.</span></p>
<p>Built by <a href="https://raghavsood.com" target="_blank" class="hover:underline hover:text-slate-200 hover:decoration-dotted text-sky-400/70">Raghav Sood</a>.</p>
<p>burned.money is licensed under <span class="inline-flex"><a href="https://creativecommons.org/licenses/by/4.0/" target="_blank" rel="license noopener noreferrer" class="hover:underline hover:text-slate-200 hover:decoration-dotted text-sky-400/70">CC BY 4.0</a>.</span></p>
<p>Running <a href="https://github.com/RaghavSood/btcsupply/tree/{{ GitCommit }}" target="_blank" class="hover:underline hover:text-slate-200 hover:decoration-dotted text-sky-400/70" target="_blank">{{ slice GitCommit 0 7 }}</a>.</p>
</footer>
{{ end }}

1 change: 1 addition & 0 deletions templates/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
15 changes: 15 additions & 0 deletions util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"html/template"
"runtime/debug"
"time"

"github.com/RaghavSood/btcsupply/notes"
Expand Down Expand Up @@ -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"
}

0 comments on commit 57be149

Please sign in to comment.