[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>
This commit is contained in:
6543 2020-09-05 18:42:58 +02:00 committed by GitHub
parent 9fdb4f887b
commit bc11caff94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 1134 additions and 966 deletions

View file

@ -243,7 +243,9 @@ func Config(ctx *context.Context) {
ctx.Data["DisableRouterLog"] = setting.DisableRouterLog
ctx.Data["RunUser"] = setting.RunUser
ctx.Data["RunMode"] = strings.Title(macaron.Env)
ctx.Data["GitVersion"], _ = git.BinVersion()
if version, err := git.LocalVersion(); err == nil {
ctx.Data["GitVersion"] = version.Original()
}
ctx.Data["RepoRootPath"] = setting.RepoRootPath
ctx.Data["CustomRootPath"] = setting.CustomPath
ctx.Data["StaticRootPath"] = setting.StaticRootPath

View file

@ -33,7 +33,6 @@ import (
gogit "github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
"github.com/mcuadros/go-version"
"github.com/unknwon/com"
)
@ -541,7 +540,7 @@ func LFSPointerFiles(ctx *context.Context) {
return
}
ctx.Data["PageIsSettingsLFS"] = true
binVersion, err := git.BinVersion()
err := git.LoadGitVersion()
if err != nil {
log.Fatal("Error retrieving git version: %v", err)
}
@ -586,7 +585,7 @@ func LFSPointerFiles(ctx *context.Context) {
go createPointerResultsFromCatFileBatch(catFileBatchReader, &wg, pointerChan, ctx.Repo.Repository, ctx.User)
go pipeline.CatFileBatch(shasToBatchReader, catFileBatchWriter, &wg, basePath)
go pipeline.BlobsLessThan1024FromCatFileBatchCheck(catFileCheckReader, shasToBatchWriter, &wg)
if !version.Compare(binVersion, "2.6.0", ">=") {
if git.CheckGitVersionConstraint(">= 2.6.0") != nil {
revListReader, revListWriter := io.Pipe()
shasToCheckReader, shasToCheckWriter := io.Pipe()
wg.Add(2)