File tree Expand file tree Collapse file tree 4 files changed +33
-2
lines changed
Expand file tree Collapse file tree 4 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ type SSRHandler struct {
2929func NewHandler (cfg * config.Config ) (* SSRHandler , error ) {
3030 basePageConfig := & BasePageConfig {
3131 Version : version .Version ,
32+ Commit : version .Commit ,
3233 RootURL : cfg .RootURL ,
3334 }
3435 if cfg .RootPath != "" {
Original file line number Diff line number Diff line change @@ -30,8 +30,11 @@ func init() {
3030// BasePageConfig is data that all pages require to function correctly, no matter
3131// whether error page or lobby page.
3232type BasePageConfig struct {
33- // Version is the source code version of this build.
33+ // Version is the tagged source code version of this build. Can be empty for dev
34+ // builds. Untagged commits will be of format `tag-N-gSHA`.
3435 Version string `json:"version"`
36+ // Commit that was deployed, if we didn't deploy a concrete tag.
37+ Commit string `json:"commit"`
3538 // RootPath is the path directly after the domain and before the
3639 // scribble.rs paths. For example if you host scribblers on painting.com
3740 // but already host a different website, then your API paths might have to
Original file line number Diff line number Diff line change 11{{define "footer"}}
22{{if eq .Version "dev"}}
33< a class ="footer-item " href ="https://github.com/scribble-rs/scribble.rs " target ="_blank "> {{.Version}}</ a >
4+ {{else if ne .Commit ""}}
5+ < a class ="footer-item " href ="https://github.com/scribble-rs/scribble.rs/commit/{{.Commit}} "
6+ target ="_blank "> {{.Version}}</ a >
47{{else}}
58< a class ="footer-item " href ="https://github.com/scribble-rs/scribble.rs/releases/tag/{{.Version}} "
69 target ="_blank "> {{.Version}}</ a >
Original file line number Diff line number Diff line change 22// scearios, it will default to "dev".
33package version
44
5+ import (
6+ "fmt"
7+ "regexp"
8+ )
9+
510// Version of the application.
6- var Version = "dev"
11+ var (
12+ Version = "dev"
13+ Commit = ""
14+ )
15+
16+ func init () {
17+ // We expect to get a "dirt git tag" when deploying a test version that
18+ // we did not yet finalize. We'll take it apart to allow the frontend
19+ // to put the correct link to the repository.
20+
21+ if Version != "dev" {
22+ // version-commit_count_after_version-hash
23+ hashRegex := regexp .MustCompile ("v.+?(?:-\\ d+?-g(.+?)(?:$|-))" )
24+ match := hashRegex .FindStringSubmatch (Version )
25+ fmt .Println (match , len (match ))
26+ if len (match ) == 2 {
27+ Commit = match [1 ]
28+ }
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments