aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/lfs.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2021-06-26 19:28:55 +0800
committerGitHub <noreply@github.com>2021-06-26 13:28:55 +0200
commite3c626834b34fae7728ee7869ed73ee4d1b26a26 (patch)
treeec61ea5376286a78622b95b7d849e8a299c85a28 /modules/git/lfs.go
parente673e42f7efafb184ffbe84f6998087713d8e373 (diff)
downloadgitea-e3c626834b34fae7728ee7869ed73ee4d1b26a26.tar.gz
gitea-e3c626834b34fae7728ee7869ed73ee4d1b26a26.zip
Let package git depend on setting but not opposite (#15241)
* Let package git depend on setting but not opposite * private some package variables
Diffstat (limited to 'modules/git/lfs.go')
-rw-r--r--modules/git/lfs.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/modules/git/lfs.go b/modules/git/lfs.go
new file mode 100644
index 0000000000..79049c9824
--- /dev/null
+++ b/modules/git/lfs.go
@@ -0,0 +1,37 @@
+// Copyright 2021 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package git
+
+import (
+ "sync"
+
+ logger "code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/setting"
+)
+
+var once sync.Once
+
+// CheckLFSVersion will check lfs version, if not satisfied, then disable it.
+func CheckLFSVersion() {
+ if setting.LFS.StartServer {
+ //Disable LFS client hooks if installed for the current OS user
+ //Needs at least git v2.1.2
+
+ err := LoadGitVersion()
+ if err != nil {
+ logger.Fatal("Error retrieving git version: %v", err)
+ }
+
+ if CheckGitVersionAtLeast("2.1.2") != nil {
+ setting.LFS.StartServer = false
+ logger.Error("LFS server support needs at least Git v2.1.2")
+ } else {
+ once.Do(func() {
+ GlobalCommandArgs = append(GlobalCommandArgs, "-c", "filter.lfs.required=",
+ "-c", "filter.lfs.smudge=", "-c", "filter.lfs.clean=")
+ })
+ }
+ }
+}