Skip to content

feat: unset core.hookspath in lefthook install#1292

Merged
mrexox merged 2 commits intoevilmartians:masterfrom
joevin-slq-docto:handle-corehooksPath
Feb 3, 2026
Merged

feat: unset core.hookspath in lefthook install#1292
mrexox merged 2 commits intoevilmartians:masterfrom
joevin-slq-docto:handle-corehooksPath

Conversation

@joevin-slq-docto
Copy link
Contributor

@joevin-slq-docto joevin-slq-docto commented Jan 23, 2026

Closes #1248

Context

See the issue.

Now lefthook install fail and warn loudly when either the local or global core.hooksPath is set.
lefthook install can unset it automatically using --force--reset-hooks-path.

Changes

Using git config :

Using --reset-hooks-path :

Using --force :

Comment on lines 489 to 501
if !force {
return formatHooksPathError(local, global)
}

// If force is true, warns and unsets the conflicting configurations.
if hasLocal {
log.Warnf("core.hooksPath is set locally to '%s'.", local)
}
if hasGlobal {
log.Warnf("core.hooksPath is set globally to '%s'.", global)
}

return l.unsetHooksPathConfig(local, global)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like --force to anyway install into global/local hooks path. Let users decide what they want, maybe they want lefthook to install hooks into the global hooks path? I understand that it might be a controversal approach, but I wouldn't like to limit users. What I learn every time is that the use cases of lefthook are quite wide, so I sometimes can't even imagine them.

Copy link
Member

@mrexox mrexox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thank you a lot for adding test. Will merge this and prepare the release

@mrexox mrexox merged commit ec7e8e1 into evilmartians:master Feb 3, 2026
13 checks passed
@corsonknowles
Copy link

We're running into some problems with this -- can the new behavior be configured or suppressed? Any advice on how to deal with it?

@joevin-slq-docto
Copy link
Contributor Author

Hello @corsonknowles, can you elaborate please ?

@corsonknowles
Copy link

can you elaborate please ?

We now have a plan in place to handle this upgrade.

  1. We've temporarily pinnned lefthook to an earlier version
  2. We're systematically unsetting this config on our own using our bin/setup across any of our repos
  3. When we do unpin lefthook again, we'll add error handling for our bin/setup to exercise --reset-hooks-path

I don't think we need anything else at this time, thank you for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unset core.hookspath in lefthook install

3 participants