summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2018-12-19 09:17:43 +0800
committerGitHub <noreply@github.com>2018-12-19 09:17:43 +0800
commit7fd34c051723bb792b500ed0cb34ca588ebb4efb (patch)
treebced13038fa8fd37b46b59e2533538364838ae0c /cmd
parent2a660a1de17daf58b8f7d58dea4b82b107b47536 (diff)
downloadgitea-7fd34c051723bb792b500ed0cb34ca588ebb4efb.tar.gz
gitea-7fd34c051723bb792b500ed0cb34ca588ebb4efb.zip
fix lfs version check warning log when using ssh protocol (#5501)
Diffstat (limited to 'cmd')
-rw-r--r--cmd/hook.go12
-rw-r--r--cmd/serv.go22
2 files changed, 25 insertions, 9 deletions
diff --git a/cmd/hook.go b/cmd/hook.go
index 63cb605929..bde449ccdc 100644
--- a/cmd/hook.go
+++ b/cmd/hook.go
@@ -10,7 +10,6 @@ import (
"fmt"
"net/url"
"os"
- "path/filepath"
"strconv"
"strings"
@@ -63,11 +62,6 @@ var (
}
)
-func hookSetup(logPath string) {
- setting.NewContext()
- log.NewGitLogger(filepath.Join(setting.LogRootPath, logPath))
-}
-
func runHookPreReceive(c *cli.Context) error {
if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
return nil
@@ -79,7 +73,7 @@ func runHookPreReceive(c *cli.Context) error {
setting.CustomConf = c.GlobalString("config")
}
- hookSetup("hooks/pre-receive.log")
+ setup("hooks/pre-receive.log")
// the environment setted on serv command
repoID, _ := strconv.ParseInt(os.Getenv(models.ProtectedBranchRepoID), 10, 64)
@@ -155,7 +149,7 @@ func runHookUpdate(c *cli.Context) error {
setting.CustomConf = c.GlobalString("config")
}
- hookSetup("hooks/update.log")
+ setup("hooks/update.log")
return nil
}
@@ -171,7 +165,7 @@ func runHookPostReceive(c *cli.Context) error {
setting.CustomConf = c.GlobalString("config")
}
- hookSetup("hooks/post-receive.log")
+ setup("hooks/post-receive.log")
// the environment setted on serv command
repoID, _ := strconv.ParseInt(os.Getenv(models.ProtectedBranchRepoID), 10, 64)
diff --git a/cmd/serv.go b/cmd/serv.go
index c98228745d..ec2258412f 100644
--- a/cmd/serv.go
+++ b/cmd/serv.go
@@ -14,6 +14,7 @@ import (
"strings"
"time"
+ "code.gitea.io/git"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/pprof"
@@ -22,6 +23,7 @@ import (
"github.com/Unknwon/com"
"github.com/dgrijalva/jwt-go"
+ version "github.com/mcuadros/go-version"
"github.com/urfave/cli"
)
@@ -48,8 +50,28 @@ var CmdServ = cli.Command{
},
}
+func checkLFSVersion() {
+ if setting.LFS.StartServer {
+ //Disable LFS client hooks if installed for the current OS user
+ //Needs at least git v2.1.2
+ binVersion, err := git.BinVersion()
+ if err != nil {
+ fail(fmt.Sprintf("Error retrieving git version: %v", err), fmt.Sprintf("Error retrieving git version: %v", err))
+ }
+
+ if !version.Compare(binVersion, "2.1.2", ">=") {
+ setting.LFS.StartServer = false
+ println("LFS server support needs at least Git v2.1.2, disabled")
+ } else {
+ git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "filter.lfs.required=",
+ "-c", "filter.lfs.smudge=", "-c", "filter.lfs.clean=")
+ }
+ }
+}
+
func setup(logPath string) {
setting.NewContext()
+ checkLFSVersion()
log.NewGitLogger(filepath.Join(setting.LogRootPath, logPath))
}