mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
tea version and --version printed "Version: development<TAB>golang: 1.27.2". They now print "tea version 1.0.0 (2026-10-01)", the release notes URL for tagged releases, and "built with go1.27.2" with the build tags. Builds from go install take the module version from the build info, and the date comes from the commit the binary was built from. Signed-off-by: bircni <bircni@icloud.com>
31 lines
1.4 KiB
Go
31 lines
1.4 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package version
|
|
|
|
import (
|
|
"runtime/debug"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestFormatDescribesTheBuild(t *testing.T) {
|
|
stamped := &debug.BuildInfo{Settings: []debug.BuildSetting{{Key: "vcs.time", Value: "2026-10-01T09:30:00Z"}}}
|
|
for _, tc := range []struct {
|
|
name, version, tags string
|
|
info *debug.BuildInfo
|
|
want string
|
|
}{
|
|
{"release", "1.0.0", "", stamped, "tea version 1.0.0 (2026-10-01)\nhttps://gitea.com/gitea/tea/releases/tag/v1.0.0\nbuilt with go1.27.2"},
|
|
{"release candidate with tags", "1.1.0-rc1", "sqlite netgo", nil, "tea version 1.1.0-rc1\nhttps://gitea.com/gitea/tea/releases/tag/v1.1.0-rc1\nbuilt with go1.27.2 (tags: sqlite, netgo)"},
|
|
{"between releases", "0.16.0+12-gabcdef", "", stamped, "tea version 0.16.0+12-gabcdef (2026-10-01)\nbuilt with go1.27.2"},
|
|
{"go install", "development", "", &debug.BuildInfo{Main: debug.Module{Version: "v1.0.1"}}, "tea version 1.0.1\nhttps://gitea.com/gitea/tea/releases/tag/v1.0.1\nbuilt with go1.27.2"},
|
|
{"local build", "development", "", &debug.BuildInfo{Main: debug.Module{Version: "(devel)"}}, "tea version development\nbuilt with go1.27.2"},
|
|
} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
require.Equal(t, tc.want, format(tc.version, tc.tags, "go1.27.2", tc.info))
|
|
})
|
|
}
|
|
}
|