aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2023-02-18 18:49:23 +0200
committerArthur Zamarin <arthurzam@gentoo.org>2023-02-18 18:49:23 +0200
commiteffa24087011298648f067b321052d2c9c7d1708 (patch)
tree446f4ff98381a3cf77593ecd74d9356ecf808063
parentdependencies: add support for IDEPEND (diff)
downloadsoko-effa24087011298648f067b321052d2c9c7d1708.tar.gz
soko-effa24087011298648f067b321052d2c9c7d1708.tar.bz2
soko-effa24087011298648f067b321052d2c9c7d1708.zip
about: show commit id
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r--pkg/app/handler/about/utils.go14
-rw-r--r--web/templates/about/index.tmpl2
2 files changed, 15 insertions, 1 deletions
diff --git a/pkg/app/handler/about/utils.go b/pkg/app/handler/about/utils.go
index e7d692b..63ca40a 100644
--- a/pkg/app/handler/about/utils.go
+++ b/pkg/app/handler/about/utils.go
@@ -5,6 +5,7 @@ package about
import (
"html/template"
"net/http"
+ "runtime/debug"
"soko/pkg/app/utils"
"soko/pkg/models"
)
@@ -20,14 +21,27 @@ func renderAboutTemplate(w http.ResponseWriter, r *http.Request, page string) {
templates.ExecuteTemplate(w, page+".tmpl", getPageData())
}
+func getCommitId() string {
+ if info, ok := debug.ReadBuildInfo(); ok {
+ for _, setting := range info.Settings {
+ if setting.Key == "vcs.revision" {
+ return setting.Value[:8]
+ }
+ }
+ }
+ return ""
+}
+
// getPageData returns the data used
// in all about templates
func getPageData() interface{} {
return struct {
Header models.Header
Application models.Application
+ CommitId string
}{
Header: models.Header{Title: "About – ", Tab: "about"},
Application: utils.GetApplicationData(),
+ CommitId: getCommitId(),
}
}
diff --git a/web/templates/about/index.tmpl b/web/templates/about/index.tmpl
index f280b64..af72f4f 100644
--- a/web/templates/about/index.tmpl
+++ b/web/templates/about/index.tmpl
@@ -23,7 +23,7 @@
<dl>
<dt>Which version is currently running?</dt>
<dd>
- Currently {{.Application.Version}} is running.
+ Currently {{.Application.Version}} is running{{if ne .CommitId ""}}, based on commit {{.CommitId}}{{end}}.
</dd>
<br>
<dt>How often is the site updated?</dt>