@@ -693,6 +693,27 @@ func createPIDFile(pidPath string) {
693693 }
694694}
695695
696+ // CheckLFSVersion will check lfs version, if not satisfied, then disable it.
697+ func CheckLFSVersion () {
698+ if LFS .StartServer {
699+ //Disable LFS client hooks if installed for the current OS user
700+ //Needs at least git v2.1.2
701+
702+ binVersion , err := git .BinVersion ()
703+ if err != nil {
704+ log .Fatal (4 , "Error retrieving git version: %v" , err )
705+ }
706+
707+ if ! version .Compare (binVersion , "2.1.2" , ">=" ) {
708+ LFS .StartServer = false
709+ log .Error (4 , "LFS server support needs at least Git v2.1.2" )
710+ } else {
711+ git .GlobalCommandArgs = append (git .GlobalCommandArgs , "-c" , "filter.lfs.required=" ,
712+ "-c" , "filter.lfs.smudge=" , "-c" , "filter.lfs.clean=" )
713+ }
714+ }
715+ }
716+
696717// NewContext initializes configuration context.
697718// NOTE: do not print any log except error.
698719func NewContext () {
@@ -888,7 +909,6 @@ func NewContext() {
888909 LFS .HTTPAuthExpiry = sec .Key ("LFS_HTTP_AUTH_EXPIRY" ).MustDuration (20 * time .Minute )
889910
890911 if LFS .StartServer {
891-
892912 if err := os .MkdirAll (LFS .ContentPath , 0700 ); err != nil {
893913 log .Fatal (4 , "Failed to create '%s': %v" , LFS .ContentPath , err )
894914 }
@@ -922,26 +942,6 @@ func NewContext() {
922942 return
923943 }
924944 }
925-
926- //Disable LFS client hooks if installed for the current OS user
927- //Needs at least git v2.1.2
928-
929- binVersion , err := git .BinVersion ()
930- if err != nil {
931- log .Fatal (4 , "Error retrieving git version: %v" , err )
932- }
933-
934- if ! version .Compare (binVersion , "2.1.2" , ">=" ) {
935-
936- LFS .StartServer = false
937- log .Error (4 , "LFS server support needs at least Git v2.1.2" )
938-
939- } else {
940-
941- git .GlobalCommandArgs = append (git .GlobalCommandArgs , "-c" , "filter.lfs.required=" ,
942- "-c" , "filter.lfs.smudge=" , "-c" , "filter.lfs.clean=" )
943-
944- }
945945 }
946946
947947 sec = Cfg .Section ("security" )
0 commit comments