From 4315a3cea3452c6b1b5d18abdd500c873a10782a Mon Sep 17 00:00:00 2001 From: Florian Kinder Date: Sun, 12 Apr 2026 13:09:28 +0200 Subject: [PATCH] fix: append -dirty suffix when built from modified worktree --- internal/cmd/root.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/cmd/root.go b/internal/cmd/root.go index b28979e..a6ab77f 100644 --- a/internal/cmd/root.go +++ b/internal/cmd/root.go @@ -65,6 +65,7 @@ func newVersionCmd() *cobra.Command { func vcsInfo() (commit, date string) { commit, date = "unknown", "unknown" + var modified bool info, ok := debug.ReadBuildInfo() if !ok { return @@ -72,15 +73,20 @@ func vcsInfo() (commit, date string) { for _, s := range info.Settings { switch s.Key { case "vcs.revision": - if len(s.Value) >= 7 { + if len(s.Value) > 7 { commit = s.Value[:7] } else { commit = s.Value } case "vcs.time": date = s.Value + case "vcs.modified": + modified = s.Value == "true" } } + if modified { + commit += "-dirty" + } return }