Move readonly config check to before lock client instantiation

This commit is contained in:
Steve Streeting 2017-01-06 09:37:31 +00:00
parent e1068a2921
commit 581e109ff6
3 changed files with 19 additions and 6 deletions

@ -25,6 +25,11 @@ func postCheckoutCommand(cmd *cobra.Command, args []string) {
os.Exit(1)
}
// Skip entire hook if lockable read only feature is disabled
if !cfg.Os.Bool("GIT_LFS_SET_LOCKABLE_READONLY", true) {
os.Exit(0)
}
requireGitVersion()
lockClient, err := locking.NewClient(cfg)
@ -33,8 +38,7 @@ func postCheckoutCommand(cmd *cobra.Command, args []string) {
}
// Skip this hook if no lockable patterns have been configured
if len(lockClient.GetLockablePatterns()) == 0 ||
!cfg.Os.Bool("GIT_LFS_SET_LOCKABLE_READONLY", true) {
if len(lockClient.GetLockablePatterns()) == 0 {
os.Exit(0)
}

@ -17,6 +17,12 @@ import (
// locked. If we didn't do this, any added files would remain read/write on disk
// even without a lock unless something else checked.
func postCommitCommand(cmd *cobra.Command, args []string) {
// Skip entire hook if lockable read only feature is disabled
if !cfg.Os.Bool("GIT_LFS_SET_LOCKABLE_READONLY", true) {
os.Exit(0)
}
requireGitVersion()
lockClient, err := locking.NewClient(cfg)
@ -25,8 +31,7 @@ func postCommitCommand(cmd *cobra.Command, args []string) {
}
// Skip this hook if no lockable patterns have been configured
if len(lockClient.GetLockablePatterns()) == 0 ||
!cfg.Os.Bool("GIT_LFS_SET_LOCKABLE_READONLY", true) {
if len(lockClient.GetLockablePatterns()) == 0 {
os.Exit(0)
}

@ -18,6 +18,11 @@ func postMergeCommand(cmd *cobra.Command, args []string) {
os.Exit(1)
}
// Skip entire hook if lockable read only feature is disabled
if !cfg.Os.Bool("GIT_LFS_SET_LOCKABLE_READONLY", true) {
os.Exit(0)
}
requireGitVersion()
lockClient, err := locking.NewClient(cfg)
@ -26,8 +31,7 @@ func postMergeCommand(cmd *cobra.Command, args []string) {
}
// Skip this hook if no lockable patterns have been configured
if len(lockClient.GetLockablePatterns()) == 0 ||
!cfg.Os.Bool("GIT_LFS_SET_LOCKABLE_READONLY", true) {
if len(lockClient.GetLockablePatterns()) == 0 {
os.Exit(0)
}