Take the version from the git tag, not a constant (closes #80)
check / check (push) Waiting to run

`mfer version`, `mfer --version` and the banner print the revision the
build stamps into main.Gitrev or, when it stamped none (as after
`go install` of a tag), the main module's version from
runtime/debug.ReadBuildInfo. The banner no longer shows a release date.

mfer.Version and mfer.ReleaseDate go, with main.Version and the version
field and parameter in internal/cli that nothing read. A program using
the library reads the module version from its own build information.
The README says where the version comes from.

Judgement call: a binary with no build information, or none holding a
module version, prints "unknown", the word script/build already uses
when git describe gives nothing.

Model: opus-5-5
This commit was merged in pull request #204.
This commit is contained in:
2026-10-14 00:00:35 +02:00
parent 60dbcc03bc
commit 9199444d11
7 changed files with 73 additions and 36 deletions
+4 -6
View File
@@ -10,14 +10,12 @@ import (
// Appname is the name of this program.
const Appname = "mfer"
// Version and Gitrev are injected at build time via -ldflags.
// Gitrev is the revision `mfer version` prints, injected at build time via
// -ldflags.
//
//nolint:gochecknoglobals // set via ldflags at build time
var (
Version string
Gitrev string
)
var Gitrev string
func main() {
os.Exit(cli.Run(Appname, Version, Gitrev))
os.Exit(cli.Run(Appname, Gitrev))
}
+3 -4
View File
@@ -15,11 +15,10 @@ func TestAppname(t *testing.T) {
assert.Equal(t, "mfer", Appname)
}
// TestVersionDefaults documents that Version and Gitrev are empty unless
// injected at build time via -ldflags.
func TestVersionDefaults(t *testing.T) {
// TestGitrevDefault documents that Gitrev is empty unless injected at build
// time via -ldflags.
func TestGitrevDefault(t *testing.T) {
t.Parallel()
assert.Empty(t, Version)
assert.Empty(t, Gitrev)
}