Skip to content

Commit 7b28605

Browse files
committed
Fix current changelog link in gh version
Also allow pre-release tags.
1 parent 1c74227 commit 7b28605

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

command/root.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,11 @@ func colorableErr(cmd *cobra.Command) io.Writer {
143143

144144
func changelogURL(version string) string {
145145
path := "https://github.com/cli/cli"
146-
r := regexp.MustCompile(`^v\d+\.\d+.\d+$`)
146+
r := regexp.MustCompile(`^\d+\.\d+.\d+(-[\w.]+)?$`)
147147
if !r.MatchString(version) {
148148
return fmt.Sprintf("%s/releases/latest", path)
149149
}
150150

151-
tag := version
152-
url := fmt.Sprintf("%s/releases/tag/%s", path, tag)
151+
url := fmt.Sprintf("%s/releases/tag/v%s", path, version)
153152
return url
154153
}

command/root_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ import (
66
)
77

88
func TestChangelogURL(t *testing.T) {
9-
tag := "v0.3.2"
9+
tag := "0.3.2"
1010
url := fmt.Sprintf("https://github.com/cli/cli/releases/tag/v0.3.2")
1111
result := changelogURL(tag)
1212
if result != url {
1313
t.Errorf("expected %s to create url %s but got %s", tag, url, result)
1414
}
1515

16+
tag = "0.3.2-pre.1"
17+
url = fmt.Sprintf("https://github.com/cli/cli/releases/tag/v0.3.2-pre.1")
18+
result = changelogURL(tag)
19+
if result != url {
20+
t.Errorf("expected %s to create url %s but got %s", tag, url, result)
21+
}
22+
1623
tag = "0.3.5-90-gdd3f0e0"
1724
url = fmt.Sprintf("https://github.com/cli/cli/releases/latest")
1825
result = changelogURL(tag)

0 commit comments

Comments
 (0)