Fix various version parsing problems (#36553)

1. handle non-release git verions (not semver)
2. fix rubygems version "0" handling (only ">=" can be omitted)
3. lazy compile the regexp to improve performance
4. make test data maintainable, use origin source code instead of compressed binary
This commit is contained in:
wxiaoguang
2026-02-09 04:25:30 +08:00
committed by GitHub
parent 2ff4f4a909
commit 08b7a30867
8 changed files with 153 additions and 47 deletions

View File

@@ -23,6 +23,10 @@ func TestParseGitVersion(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, "2.29.3", v.String())
v, err = parseGitVersionLine("git version 2.28.0.618.gf4bc123cb7")
assert.NoError(t, err)
assert.Equal(t, "2.28.0", v.String())
_, err = parseGitVersionLine("git version")
assert.Error(t, err)