From 6da4315f57d3653041e9aa43b72c350af63d03e3 Mon Sep 17 00:00:00 2001 From: sneak Date: Tue, 10 Nov 2026 19:57:35 +0000 Subject: [PATCH] Label the version report's date line "commit date" (closes #409) The value is the commit's date, which the Makefile and the Dockerfile stamp in, not the time of the build. The other labels gain one space so every value still starts in one column. Model: opus-5-5 --- internal/cli/version.go | 14 +++++++------- internal/cli/version_test.go | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/internal/cli/version.go b/internal/cli/version.go index 0307060..400d6eb 100644 --- a/internal/cli/version.go +++ b/internal/cli/version.go @@ -37,13 +37,13 @@ func writeVersion(out *ui.Writer) { w := out.Out() _, _ = fmt.Fprintf(w, "vaultik %s\n", globals.Version) - _, _ = fmt.Fprintf(w, " commit: %s\n", globals.Commit) - _, _ = fmt.Fprintf(w, " build date: %s\n", globals.CommitDate) - _, _ = fmt.Fprintf(w, " go: %s\n", runtime.Version()) - _, _ = fmt.Fprintf(w, " os/arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) - _, _ = fmt.Fprintf(w, " author: %s\n", globals.Author) - _, _ = fmt.Fprintf(w, " homepage: %s\n", globals.Homepage) - _, _ = fmt.Fprintf(w, " license: %s\n", globals.License) + _, _ = fmt.Fprintf(w, " commit: %s\n", globals.Commit) + _, _ = fmt.Fprintf(w, " commit date: %s\n", globals.CommitDate) + _, _ = fmt.Fprintf(w, " go: %s\n", runtime.Version()) + _, _ = fmt.Fprintf(w, " os/arch: %s/%s\n", runtime.GOOS, runtime.GOARCH) + _, _ = fmt.Fprintf(w, " author: %s\n", globals.Author) + _, _ = fmt.Fprintf(w, " homepage: %s\n", globals.Homepage) + _, _ = fmt.Fprintf(w, " license: %s\n", globals.License) if globals.IsDevVersion(globals.Version) { _, _ = fmt.Fprintln(w) diff --git a/internal/cli/version_test.go b/internal/cli/version_test.go index 7068f9d..607b008 100644 --- a/internal/cli/version_test.go +++ b/internal/cli/version_test.go @@ -49,6 +49,25 @@ func TestVersionCommandReportsBuildVersion(t *testing.T) { } } +// TestVersionCommandLabelsCommitDate checks that the date line is +// labelled as the commit's date, which is what the build stamps into +// it, and that its value starts in the same column as the commit's. +// +//nolint:paralleltest // executes a command that reads the global rootFlags +func TestVersionCommandLabelsCommitDate(t *testing.T) { + out := runVersionCommand(t) + + wantLine := " commit date: " + globals.CommitDate + if !strings.Contains(out, wantLine+"\n") { + t.Errorf("output has no line %q:\n%s", wantLine, out) + } + + wantCommit := " commit: " + globals.Commit + if !strings.Contains(out, wantCommit+"\n") { + t.Errorf("output has no line %q:\n%s", wantCommit, out) + } +} + // TestVersionCommandFlagsDevelopmentBuild is the regression test for // the thing this command exists to prevent: a build that is not a // release must say so. The notice used to be gated on the version