mirror of
https://gitea.com/gitea/tea.git
synced 2026-10-26 19:11:25 +01:00
fix(release): lightweight tags in the snap build, version fallback, man pages for help topics, draft the 1.0.0 changelog
Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
9 files changed
+100
-12
No files matched your search
+13
-4
@@ -40,10 +40,7 @@ func (a *application) manCommand() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
if len(args) == 0 {
|
||||
for _, child := range page.Commands() {
|
||||
if child.Hidden {
|
||||
continue
|
||||
}
|
||||
for _, child := range ManualCommands(page) {
|
||||
if err := render(child); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -67,3 +64,15 @@ func ManualDate(getenv func(string) string) time.Time {
|
||||
}
|
||||
return time.Date(2026, time.January, 1, 0, 0, 0, 0, time.UTC)
|
||||
}
|
||||
|
||||
// ManualCommands lists the subcommands that get a page in the manual: the available commands,
|
||||
// without the generated help command, and the help topics such as environment and exit-codes.
|
||||
func ManualCommands(page *cobra.Command) []*cobra.Command {
|
||||
var children []*cobra.Command
|
||||
for _, child := range page.Commands() {
|
||||
if child.Annotations[topicAnnotation] != "" || (child.IsAvailableCommand() && !child.IsAdditionalHelpTopicCommand()) {
|
||||
children = append(children, child)
|
||||
}
|
||||
}
|
||||
return children
|
||||
}
|
||||
@@ -66,3 +66,12 @@ func TestCanceledManDoesNotPublishOutputFile(t *testing.T) {
|
||||
require.True(t, os.IsNotExist(err))
|
||||
require.Empty(t, out.String())
|
||||
}
|
||||
|
||||
func TestManIncludesHelpTopicsButNotHelpCommands(t *testing.T) {
|
||||
deps, out, _ := testDeps(t)
|
||||
require.NoError(t, Execute(context.Background(), deps, []string{"man"}))
|
||||
manual := out.String()
|
||||
require.Contains(t, manual, `.TH "TEA-ENVIRONMENT"`)
|
||||
require.Contains(t, manual, `.TH "TEA-EXIT-CODES"`)
|
||||
require.NotContains(t, manual, `.TH "TEA-PR-HELP"`)
|
||||
}
|
||||
@@ -111,7 +111,7 @@ type Client struct {
|
||||
}
|
||||
|
||||
// UserAgent identifies tea to instances, proxies, and server logs.
|
||||
var UserAgent = "tea/" + version.Version + " (" + runtime.GOOS + "/" + runtime.GOARCH + ")"
|
||||
var UserAgent = "tea/" + version.Current() + " (" + runtime.GOOS + "/" + runtime.GOARCH + ")"
|
||||
|
||||
type userAgentTransport struct{ base http.RoundTripper }
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ func TestTransportBoundsOnlySetupAndSendsUserAgent(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, response.Body.Close())
|
||||
}
|
||||
want := "tea/" + version.Version + " (" + runtime.GOOS + "/" + runtime.GOARCH + ")"
|
||||
want := "tea/" + version.Current() + " (" + runtime.GOOS + "/" + runtime.GOARCH + ")"
|
||||
require.Equal(t, []string{want, want}, agents)
|
||||
}
|
||||
|
||||
|
||||
@@ -36,13 +36,29 @@ func Format() string {
|
||||
return format(Version, Tags, runtime.Version(), info)
|
||||
}
|
||||
|
||||
// Current returns the version of this build: the ldflags stamp, else the module version recorded
|
||||
// by go install, else "development".
|
||||
func Current() string {
|
||||
info, _ := debug.ReadBuildInfo()
|
||||
return resolve(Version, info)
|
||||
}
|
||||
|
||||
func resolve(version string, info *debug.BuildInfo) string {
|
||||
// A build without a checkout (a source archive) stamps an empty version.
|
||||
if version != "" && version != "development" {
|
||||
return version
|
||||
}
|
||||
// go install gitea.dev/tea@v1.0.0 stamps the module version instead of the ldflags.
|
||||
if info != nil && info.Main.Version != "" && info.Main.Version != "(devel)" {
|
||||
return strings.TrimPrefix(info.Main.Version, "v")
|
||||
}
|
||||
return "development"
|
||||
}
|
||||
|
||||
func format(version, tags, goVersion string, info *debug.BuildInfo) string {
|
||||
version = resolve(version, info)
|
||||
date := ""
|
||||
if info != nil {
|
||||
// go install gitea.dev/tea@v1.0.0 stamps the module version instead of the ldflags.
|
||||
if version == "development" && info.Main.Version != "" && info.Main.Version != "(devel)" {
|
||||
version = strings.TrimPrefix(info.Main.Version, "v")
|
||||
}
|
||||
for _, setting := range info.Settings {
|
||||
if setting.Key != "vcs.time" {
|
||||
continue
|
||||
|
||||
@@ -28,3 +28,12 @@ func TestFormatDescribesTheBuild(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveFallsBackWhenUnstamped(t *testing.T) {
|
||||
installed := &debug.BuildInfo{Main: debug.Module{Version: "v1.0.1"}}
|
||||
require.Equal(t, "1.0.1", resolve("development", installed))
|
||||
require.Equal(t, "1.0.1", resolve("", installed))
|
||||
require.Equal(t, "development", resolve("", nil))
|
||||
require.Equal(t, "development", resolve("", &debug.BuildInfo{Main: debug.Module{Version: "(devel)"}}))
|
||||
require.Equal(t, "1.0.0", resolve("1.0.0", installed))
|
||||
}
|
||||
Reference in new issue
Block a user