Skip to content

Commit

Permalink
fix: skip git-lfs on pre-push hook when calling manually
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox committed Oct 23, 2024
1 parent fa89715 commit f644269
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
19 changes: 7 additions & 12 deletions internal/git/lfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ const (
LFSConfigFile = ".lfsconfig"
)

var lfsHooks = [...]string{
"post-checkout",
"post-commit",
"post-merge",
"pre-push",
var lfsHooks = map[string]struct{}{
"post-checkout": {},
"post-commit": {},
"post-merge": {},
"pre-push": {},
}

// IsLFSAvailable returns 'true' if git-lfs is installed.
Expand All @@ -25,11 +25,6 @@ func IsLFSAvailable() bool {

// IsLFSHook returns whether the hookName is supported by Git LFS.
func IsLFSHook(hookName string) bool {
for _, lfsHookName := range lfsHooks {
if lfsHookName == hookName {
return true
}
}

return false
_, ok := lfsHooks[hookName]
return ok
}
5 changes: 5 additions & 0 deletions internal/lefthook/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ func (r *Runner) runLFSHook(ctx context.Context) error {
return nil
}

// Skip triggering LFS for pre-push hook when triggered manually
if len(r.GitArgs) == 0 && r.HookName == "pre-push" {
return nil
}

lfsRequiredFile := filepath.Join(r.Repo.RootPath, git.LFSRequiredFile)
lfsConfigFile := filepath.Join(r.Repo.RootPath, git.LFSConfigFile)

Expand Down

0 comments on commit f644269

Please sign in to comment.