Skip to content

Commit 8ac1f94

Browse files
authored
fix(builder/cask): correctly resolve version with build variant to release name (#140)
1 parent cc38319 commit 8ac1f94

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

pkg/release/version.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"errors"
55
"fmt"
66
"regexp"
7-
"strings"
87
)
98

109
// Errors
@@ -18,8 +17,9 @@ var (
1817
)
1918

2019
var (
21-
stableVersion = regexp.MustCompile(`^\d+\.\d+(?:[a-z]+)?$`)
22-
stableGitRef = regexp.MustCompile(`^emacs-(\d+\.\d+(?:[a-z]+)?)$`)
20+
stableVersion = regexp.MustCompile(`^\d+\.\d+(?:[a-z]+)?(-\d+)?$`)
21+
pretestVersion = regexp.MustCompile(`-pretest(-\d+)?$`)
22+
stableGitRef = regexp.MustCompile(`^emacs-(\d+\.\d+(?:[a-z]+)?)$`)
2323
)
2424

2525
func VersionToName(version string) (string, error) {
@@ -28,7 +28,7 @@ func VersionToName(version string) (string, error) {
2828
}
2929

3030
if stableVersion.MatchString(version) ||
31-
strings.HasSuffix(version, "-pretest") {
31+
pretestVersion.MatchString(version) {
3232
return "Emacs-" + version, nil
3333
}
3434

pkg/release/version_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,27 @@ func TestVersionToName(t *testing.T) {
3030
},
3131
want: "Emacs.2021-07-01.1b88404.master",
3232
},
33+
{
34+
name: "nightly with variant",
35+
args: args{
36+
version: "2021-07-01.1b88404.master-1",
37+
},
38+
want: "Emacs.2021-07-01.1b88404.master-1",
39+
},
40+
{
41+
name: "pretest",
42+
args: args{
43+
version: "30.0.93-pretest",
44+
},
45+
want: "Emacs-30.0.93-pretest",
46+
},
47+
{
48+
name: "pretest with variant",
49+
args: args{
50+
version: "30.0.93-pretest-1",
51+
},
52+
want: "Emacs-30.0.93-pretest-1",
53+
},
3354
{
3455
name: "stable",
3556
args: args{
@@ -44,6 +65,20 @@ func TestVersionToName(t *testing.T) {
4465
},
4566
want: "Emacs-23.3b",
4667
},
68+
{
69+
name: "stable with variant",
70+
args: args{
71+
version: "23.3-1",
72+
},
73+
want: "Emacs-23.3-1",
74+
},
75+
{
76+
name: "stable with letter and variant",
77+
args: args{
78+
version: "23.3b-1",
79+
},
80+
want: "Emacs-23.3b-1",
81+
},
4782
}
4883
for _, tt := range tests {
4984
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)