X Tutup
Skip to content

Commit 18b19e0

Browse files
committed
Fix link in version output
It now correctly links to the tagged release instead of to the latest release.
1 parent 04e6446 commit 18b19e0

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pkg/cmd/version/version.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ func NewCmdVersion(f *cmdutil.Factory, version, buildDate string) *cobra.Command
2626
func Format(version, buildDate string) string {
2727
version = strings.TrimPrefix(version, "v")
2828

29+
var dateStr string
2930
if buildDate != "" {
30-
version = fmt.Sprintf("%s (%s)", version, buildDate)
31+
dateStr = fmt.Sprintf(" (%s)", buildDate)
3132
}
3233

33-
return fmt.Sprintf("gh version %s\n%s\n", version, changelogURL(version))
34+
return fmt.Sprintf("gh version %s%s\n%s\n", version, dateStr, changelogURL(version))
3435
}
3536

3637
func changelogURL(version string) string {

pkg/cmd/version/version_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ import (
44
"testing"
55
)
66

7+
func TestFormat(t *testing.T) {
8+
expects := "gh version 1.4.0 (2020-12-15)\nhttps://github.com/cli/cli/releases/tag/v1.4.0\n"
9+
if got := Format("1.4.0", "2020-12-15"); got != expects {
10+
t.Errorf("Format() = %q, wants %q", got, expects)
11+
}
12+
}
13+
714
func TestChangelogURL(t *testing.T) {
815
tag := "0.3.2"
916
url := "https://github.com/cli/cli/releases/tag/v0.3.2"

0 commit comments

Comments
 (0)
X Tutup