File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed
Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -143,12 +143,11 @@ func colorableErr(cmd *cobra.Command) io.Writer {
143143
144144func 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}
Original file line number Diff line number Diff line change @@ -6,13 +6,20 @@ import (
66)
77
88func 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 )
You can’t perform that action at this time.
0 commit comments