aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/git.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-10-21 16:42:08 +0100
committerGitHub <noreply@github.com>2020-10-21 11:42:08 -0400
commitde6e427a0188ef1be6108c5a71979dc4dd679aec (patch)
treeac0d5a17dcac25c4a6f702b6949123d527027002 /modules/git/git.go
parent53359b1861c79ea688a3c230d235fb515eb44c01 (diff)
downloadgitea-de6e427a0188ef1be6108c5a71979dc4dd679aec.tar.gz
gitea-de6e427a0188ef1be6108c5a71979dc4dd679aec.zip
go-version constraints ignore pre-releases (#13234)
Go-version constraints ignore pre-releases. Rather than change the library further this PR simply changes the git version comparison to use simple version compare ignoring the issue of pre-releases. Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/git/git.go')
-rw-r--r--modules/git/git.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/modules/git/git.go b/modules/git/git.go
index a9ff923cc5..cce5cc738d 100644
--- a/modules/git/git.go
+++ b/modules/git/git.go
@@ -150,13 +150,13 @@ func Init(ctx context.Context) error {
return err
}
- if CheckGitVersionConstraint(">= 2.10") == nil {
+ if CheckGitVersionAtLeast("2.10") == nil {
if err := checkAndSetConfig("receive.advertisePushOptions", "true", true); err != nil {
return err
}
}
- if CheckGitVersionConstraint(">= 2.18") == nil {
+ if CheckGitVersionAtLeast("2.18") == nil {
if err := checkAndSetConfig("core.commitGraph", "true", true); err != nil {
return err
}
@@ -173,17 +173,17 @@ func Init(ctx context.Context) error {
return nil
}
-// CheckGitVersionConstraint check version constrain against local installed git version
-func CheckGitVersionConstraint(constraint string) error {
+// CheckGitVersionAtLeast check git version is at least the constraint version
+func CheckGitVersionAtLeast(atLeast string) error {
if err := LoadGitVersion(); err != nil {
return err
}
- check, err := version.NewConstraint(constraint)
+ atLeastVersion, err := version.NewVersion(atLeast)
if err != nil {
return err
}
- if !check.Check(gitVersion) {
- return fmt.Errorf("installed git binary %s does not satisfy version constraint %s", gitVersion.Original(), constraint)
+ if gitVersion.Compare(atLeastVersion) < 0 {
+ return fmt.Errorf("installed git binary version %s is not at least %s", gitVersion.Original(), atLeast)
}
return nil
}