Skip to content

Commit b8a3b6d

Browse files
committed
version: cut 'g' prefix from hash part of tarantool version
1 parent 74f6bc1 commit b8a3b6d

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

cli/install/install.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -1255,13 +1255,11 @@ func isUpdatePossible(installCtx InstallCtx,
12551255
if err != nil {
12561256
return false, err
12571257
}
1258-
// We need to trim first rune to get commit hash
1259-
// from string structure 'g<commitHash>'.
1260-
if len(binVersion.Hash) < 1 {
1258+
if len(binVersion.Hash) == 0 {
12611259
return false, fmt.Errorf("could not get commit hash of the version"+
12621260
"of an installed %s", program)
12631261
}
1264-
curBinHash = binVersion.Hash[1:]
1262+
curBinHash = binVersion.Hash
12651263
} else if program == search.ProgramTt {
12661264
ttVer, err := cmdcontext.GetTtVersion(pathToBin)
12671265
if err != nil {

cli/version/version_tools.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func createVersionRegexp(isStrict bool) *regexp.Regexp {
8585
`v?(?:(?P<major>\d+)){1}(?:\.(?P<minor>\d+)){1}(?:\.(?P<patch>\d+)){1}` +
8686
`(?:-(?P<release>entrypoint|rc|alpha|beta)(?P<releaseNum>\d+)?)?` +
8787
`(?:-(?P<additional>\d+))?` +
88-
`(?:-(?P<hash>g[a-f0-9]+))?(?:-r(?P<revision>\d+))?(-gc64|-nogc64)?$`
88+
`(?:-g(?P<hash>[a-f0-9]+))?(?:-r(?P<revision>\d+))?(-gc64|-nogc64)?$`
8989
if !isStrict {
9090
matchString = strings.Replace(matchString, "{1}", "?", 3)
9191
}

cli/version/version_tools_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestParseVersion(t *testing.T) {
2424
Patch: 42,
2525
Release: Release{Type: TypeAlpha, Num: 2, str: "alpha2"},
2626
Additional: 91,
27-
Hash: "g08c9b4963",
27+
Hash: "08c9b4963",
2828
Revision: 482,
2929
Str: "2.10.42-alpha2-91-g08c9b4963-r482",
3030
},
@@ -38,7 +38,7 @@ func TestParseVersion(t *testing.T) {
3838
Patch: 13,
3939
Release: Release{Type: TypeRelease},
4040
Additional: 48,
41-
Hash: "ga3a42eec7",
41+
Hash: "a3a42eec7",
4242
Revision: 496,
4343
Str: "1.10.13-48-ga3a42eec7-r496",
4444
},
@@ -52,7 +52,7 @@ func TestParseVersion(t *testing.T) {
5252
Patch: 0,
5353
Release: Release{Type: TypeRelease},
5454
Additional: 0,
55-
Hash: "gc9673ebb7",
55+
Hash: "c9673ebb7",
5656
Revision: 575,
5757
Str: "2.11.0-0-gc9673ebb7-r575-nogc64",
5858
},
@@ -66,7 +66,7 @@ func TestParseVersion(t *testing.T) {
6666
Patch: 0,
6767
Release: Release{Type: TypeRelease},
6868
Additional: 0,
69-
Hash: "gc9673ebb7",
69+
Hash: "c9673ebb7",
7070
Revision: 575,
7171
Str: "2.11.0-0-gc9673ebb7-r575-gc64",
7272
},
@@ -80,7 +80,7 @@ func TestParseVersion(t *testing.T) {
8080
Patch: 123,
8181
Release: Release{Type: TypeRC, Num: 1, str: "rc1"},
8282
Additional: 100,
83-
Hash: "g2ba6c0",
83+
Hash: "2ba6c0",
8484
Str: "1.10.123-rc1-100-g2ba6c0",
8585
},
8686
nil,

0 commit comments

Comments
 (0)