aboutsummaryrefslogtreecommitdiffstats
path: root/repository
diff options
context:
space:
mode:
Diffstat (limited to 'repository')
-rw-r--r--repository/git.go13
1 files changed, 11 insertions, 2 deletions
diff --git a/repository/git.go b/repository/git.go
index 9ec7905a..dfd7fed4 100644
--- a/repository/git.go
+++ b/repository/git.go
@@ -7,6 +7,7 @@ import (
"io"
"os/exec"
"path"
+ "regexp"
"strconv"
"strings"
@@ -331,8 +332,16 @@ func (repo *GitRepo) gitVersionLT218() (bool, error) {
return false, err
}
- versionString := strings.Fields(versionOut)[2]
- version, err := semver.Make(versionString)
+ // extract the version and truncate potential bad parts
+ // ex: 2.23.0.rc1 instead of 2.23.0-rc1
+ r := regexp.MustCompile(`(\d+\.){1,2}\d+`)
+
+ extracted := r.FindString(versionOut)
+ if extracted == "" {
+ return false, fmt.Errorf("unreadable git version %s", versionOut)
+ }
+
+ version, err := semver.Make(extracted)
if err != nil {
return false, err
}