mirror of
https://github.com/lunchcat/sif.git
synced 2026-06-12 11:01:24 -07:00
661480a56d
- add internal/version: resolve from the release ldflag, else the go build info (module tag / vcs revision), else "dev" - show the version on the boot banner and for `sif version` - Makefile now stamps `make` builds via git describe (matching the release ci), so local/go-install builds report a real version instead of "dev" - patchnotes.ShowOnce skips pseudo/dev versions so non-release builds dont make a doomed github call - document sif version / sif patchnote / SIF_NO_PATCHNOTES in the readme + usage
44 lines
1.8 KiB
Go
44 lines
1.8 KiB
Go
/*
|
|
·━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━·
|
|
: :
|
|
: █▀ █ █▀▀ · Blazing-fast pentesting suite :
|
|
: ▄█ █ █▀ · BSD 3-Clause License :
|
|
: :
|
|
: (c) 2022-2026 vmfunc, xyzeva, :
|
|
: lunchcat alumni & contributors :
|
|
: :
|
|
·━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━·
|
|
*/
|
|
|
|
package version
|
|
|
|
import "testing"
|
|
|
|
func TestResolveLdflag(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
ldflag string
|
|
want string
|
|
}{
|
|
{"tag with v", "v2026.6.7", "2026.6.7"},
|
|
{"tag without v", "2026.6.7", "2026.6.7"},
|
|
{"pseudo version", "2026.2.17-57-geb33321", "2026.2.17-57-geb33321"},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := Resolve(tt.ldflag); got != tt.want {
|
|
t.Errorf("Resolve(%q) = %q, want %q", tt.ldflag, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
// with no ldflag, Resolve falls back to build info; in a test binary that's
|
|
// non-deterministic, so just assert it never returns an empty string.
|
|
func TestResolveFallbackNonEmpty(t *testing.T) {
|
|
if Resolve("dev") == "" {
|
|
t.Error("Resolve fallback should never be empty")
|
|
}
|
|
}
|