Skip to content

Commit e969587

Browse files
Support an optional 'v' in semver present in the binary archive (#47)
Co-authored-by: Kuba Raczkowski <[email protected]>
1 parent 83ffad5 commit e969587

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

decompress.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func matchExecutableName(cmd, os, arch, target string) bool {
144144
cmd = strings.TrimSuffix(cmd, ".exe")
145145
pattern := regexp.MustCompile(
146146
fmt.Sprintf(
147-
`^%s([_-]%s)?([_-]%s[_-]%s)?(\.exe)?$`,
147+
`^%s([_-]v?%s)?([_-]%s[_-]%s)?(\.exe)?$`,
148148
regexp.QuoteMeta(cmd),
149149
semverPattern,
150150
regexp.QuoteMeta(os),

decompress_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,28 +124,42 @@ func TestMatchExecutableName(t *testing.T) {
124124
{"gostuff", "linux", "amd64", "gostuff", true},
125125
{"gostuff", "linux", "amd64", "gostuff_0.16.0", true},
126126
{"gostuff", "linux", "amd64", "gostuff-0.16.0", true},
127+
{"gostuff", "linux", "amd64", "gostuff_v0.16.0", true},
128+
{"gostuff", "linux", "amd64", "gostuff-v0.16.0", true},
127129
{"gostuff", "linux", "amd64", "gostuff_linux_amd64", true},
128130
{"gostuff", "linux", "amd64", "gostuff-linux-amd64", true},
129131
{"gostuff", "linux", "amd64", "gostuff_0.16.0_linux_amd64", true},
130132
{"gostuff", "linux", "amd64", "gostuff-0.16.0-linux-amd64", true},
133+
{"gostuff", "linux", "amd64", "gostuff_v0.16.0_linux_amd64", true},
134+
{"gostuff", "linux", "amd64", "gostuff-v0.16.0-linux-amd64", true},
131135
// invalid
132136
{"gostuff", "linux", "amd64", "gostuff_darwin_amd64", false},
133137
{"gostuff", "linux", "amd64", "gostuff0.16.0", false},
138+
{"gostuff", "linux", "amd64", "gostuffv0.16.0", false},
134139
{"gostuff", "linux", "amd64", "gostuff_0.16.0_amd64", false},
140+
{"gostuff", "linux", "amd64", "gostuff_v0.16.0_amd64", false},
135141
{"gostuff", "linux", "amd64", "gostuff_0.16.0_linux", false},
142+
{"gostuff", "linux", "amd64", "gostuff_v0.16.0_linux", false},
136143
// windows valid
137144
{"gostuff", "windows", "amd64", "gostuff.exe", true},
138145
{"gostuff", "windows", "amd64", "gostuff_0.16.0.exe", true},
139146
{"gostuff", "windows", "amd64", "gostuff-0.16.0.exe", true},
147+
{"gostuff", "windows", "amd64", "gostuff_v0.16.0.exe", true},
148+
{"gostuff", "windows", "amd64", "gostuff-v0.16.0.exe", true},
140149
{"gostuff", "windows", "amd64", "gostuff_windows_amd64.exe", true},
141150
{"gostuff", "windows", "amd64", "gostuff-windows-amd64.exe", true},
142151
{"gostuff", "windows", "amd64", "gostuff_0.16.0_windows_amd64.exe", true},
143152
{"gostuff", "windows", "amd64", "gostuff-0.16.0-windows-amd64.exe", true},
153+
{"gostuff", "windows", "amd64", "gostuff_v0.16.0_windows_amd64.exe", true},
154+
{"gostuff", "windows", "amd64", "gostuff-v0.16.0-windows-amd64.exe", true},
144155
// windows invalid
145156
{"gostuff", "windows", "amd64", "gostuff_darwin_amd64.exe", false},
146157
{"gostuff", "windows", "amd64", "gostuff0.16.0.exe", false},
147158
{"gostuff", "windows", "amd64", "gostuff_0.16.0_amd64.exe", false},
148159
{"gostuff", "windows", "amd64", "gostuff_0.16.0_windows.exe", false},
160+
{"gostuff", "windows", "amd64", "gostuffv0.16.0.exe", false},
161+
{"gostuff", "windows", "amd64", "gostuff_v0.16.0_amd64.exe", false},
162+
{"gostuff", "windows", "amd64", "gostuff_v0.16.0_windows.exe", false},
149163
}
150164

151165
for _, testItem := range testData {

0 commit comments

Comments
 (0)