aboutsummaryrefslogtreecommitdiffstats
path: root/modules/setting
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-09-05 18:42:58 +0200
committerGitHub <noreply@github.com>2020-09-05 12:42:58 -0400
commitbc11caff94896c8c3f9a5c970a77470ed9beb83a (patch)
tree75196365a23153cb7e9d13c368fa27d75b3aecfa /modules/setting
parent9fdb4f887b65a6ddacefc8c7e4580e333d7e4b95 (diff)
downloadgitea-bc11caff94896c8c3f9a5c970a77470ed9beb83a.tar.gz
gitea-bc11caff94896c8c3f9a5c970a77470ed9beb83a.zip
[Vendor] Switch go-version lib (#12719)
* vendor: switch from "mcuadros/go-version" to "hashicorp/go-version" * Adapt P1 * simplify * fix lint * adapt * fix lint & rm old code * no deadlock * rm RWMutex and check GoVersion only 1-time * Copyright header Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'modules/setting')
-rw-r--r--modules/setting/git.go10
-rw-r--r--modules/setting/setting.go5
2 files changed, 6 insertions, 9 deletions
diff --git a/modules/setting/git.go b/modules/setting/git.go
index f83758f387..9136ea7f17 100644
--- a/modules/setting/git.go
+++ b/modules/setting/git.go
@@ -9,8 +9,6 @@ import (
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
-
- version "github.com/mcuadros/go-version"
)
var (
@@ -71,20 +69,20 @@ func newGit() {
}
git.DefaultCommandExecutionTimeout = time.Duration(Git.Timeout.Default) * time.Second
- binVersion, err := git.BinVersion()
+ version, err := git.LocalVersion()
if err != nil {
log.Fatal("Error retrieving git version: %v", err)
}
- if version.Compare(binVersion, "2.9", ">=") {
+ if git.CheckGitVersionConstraint(">= 2.9") == nil {
// Explicitly disable credential helper, otherwise Git credentials might leak
git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "credential.helper=")
}
var format = "Git Version: %s"
- var args = []interface{}{binVersion}
+ var args = []interface{}{version.Original()}
// Since git wire protocol has been released from git v2.18
- if Git.EnableAutoGitWireProtocol && version.Compare(binVersion, "2.18", ">=") {
+ if Git.EnableAutoGitWireProtocol && git.CheckGitVersionConstraint(">= 2.18") == nil {
git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "protocol.version=2")
format += ", Wire Protocol %s Enabled"
args = append(args, "Version 2") // for focus color
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index 5b8aefdaa4..8449851efb 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -28,7 +28,6 @@ import (
"code.gitea.io/gitea/modules/user"
shellquote "github.com/kballard/go-shellquote"
- version "github.com/mcuadros/go-version"
"github.com/unknwon/com"
ini "gopkg.in/ini.v1"
"strk.kbt.io/projects/go/libravatar"
@@ -479,12 +478,12 @@ func CheckLFSVersion() {
//Disable LFS client hooks if installed for the current OS user
//Needs at least git v2.1.2
- binVersion, err := git.BinVersion()
+ err := git.LoadGitVersion()
if err != nil {
log.Fatal("Error retrieving git version: %v", err)
}
- if !version.Compare(binVersion, "2.1.2", ">=") {
+ if git.CheckGitVersionConstraint(">= 2.1.2") != nil {
LFS.StartServer = false
log.Error("LFS server support needs at least Git v2.1.2")
} else {