From e7c73ca0a9c0b5204b6d1050d0ab6f6a16be00d8 Mon Sep 17 00:00:00 2001 From: flamingcow Date: Wed, 5 Aug 2026 16:13:20 -0700 Subject: [PATCH] Reveal the build's commit hash in place of the reset label while a finger holds the top-right corner, and dev where go run left no stamp --- main.go | 1 + ui.go | 45 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index c116bbc..eadebb1 100644 --- a/main.go +++ b/main.go @@ -737,6 +737,7 @@ func run(aName, bName string, nsPerM float64) error { if disp.holdReset(x, y, down, now) { start = resetAll(dirs, stats) } + disp.showVersion = down && disp.versionSpot.contains(x, y) for i, d := range dirs { views[i] = d.displayView() } diff --git a/ui.go b/ui.go index 149d390..6fc311b 100644 --- a/ui.go +++ b/ui.go @@ -3,6 +3,7 @@ package main import ( "fmt" "math" + "runtime/debug" "time" ) @@ -41,6 +42,8 @@ const ( btnH = 80 holdDuration = time.Second + versionSpotSide = 200 + chipRadius = spaceTight chipBorder = 2 @@ -72,6 +75,10 @@ type display struct { holdStart time.Time holdFrac float64 fired bool + + version string + versionSpot rect + showVersion bool } func newDisplay() (*display, error) { @@ -79,7 +86,7 @@ func newDisplay() (*display, error) { if err != nil { return nil, err } - d := &display{fb: fb} + d := &display{fb: fb, version: buildVersion()} for _, spec := range []struct { dst **textFace bold bool @@ -130,6 +137,7 @@ func newDisplay() (*display, error) { w: btnW, h: btnH, } + d.versionSpot = rect{fb.w - versionSpotSide, 0, versionSpotSide, versionSpotSide} return d, nil } @@ -188,14 +196,17 @@ func (d *display) drawResetButton() { split += w } - label := "RESET" + label, base := "RESET", uiCyan + if d.showVersion { + label, base = d.version, uiDim + } lx := r.x + (r.w-len(label)*d.gridB.cellW)/2 ly := r.y + (r.h-d.gridB.lineH)/2 - d.gridB.capTop // The label straddles the fill, so each glyph takes the colour that reads // against whatever is behind it. for i, c := range label { gx := lx + i*d.gridB.cellW - col := uiCyan + col := base if gx+d.gridB.cellW/2 < split { col = uiBg } @@ -203,6 +214,34 @@ func (d *display) drawResetButton() { } } +// go run never stamps VCS info, so dev builds have no revision to show. +func buildVersion() string { + info, ok := debug.ReadBuildInfo() + if !ok { + return "dev" + } + var rev string + var dirty bool + for _, s := range info.Settings { + switch s.Key { + case "vcs.revision": + rev = s.Value + case "vcs.modified": + dirty = s.Value == "true" + } + } + if rev == "" { + return "dev" + } + if len(rev) > 9 { + rev = rev[:9] + } + if dirty { + rev += "+" + } + return rev +} + func (d *display) close() { d.fb.close() }