Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add run no auto install flag #716

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ func newRunCmd(opts *lefthook.Options) *cobra.Command {
"run hooks on all files",
)

runCmd.Flags().BoolVar(
&runArgs.NoAutoInstall, "no-auto-install", false,
"skip updating git hooks",
)

runCmd.Flags().BoolVar(
&runArgs.FilesFromStdin, "files-from-stdin", false,
"get files from standard input, null-separated",
Expand Down
13 changes: 8 additions & 5 deletions internal/lefthook/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type RunArgs struct {
AllFiles bool
FilesFromStdin bool
Force bool
NoAutoInstall bool
Files []string
RunOnlyCommands []string
}
Expand Down Expand Up @@ -94,12 +95,14 @@ func (l *Lefthook) Run(hookName string, args RunArgs, gitArgs []string) error {
)
}

// This line controls updating the git hook if config has changed
if err = l.createHooksIfNeeded(cfg, true, false); err != nil {
log.Warn(
`⚠️ There was a problem with synchronizing git hooks.
if !args.NoAutoInstall {
// This line controls updating the git hook if config has changed
if err = l.createHooksIfNeeded(cfg, true, false); err != nil {
log.Warn(
`⚠️ There was a problem with synchronizing git hooks.
Run 'lefthook install' manually.`,
)
)
}
}

// Find the hook
Expand Down
Loading