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

lefthook install does not seem to recreate .git/hooks if it has been deleted #571

Closed
technicalpickles opened this issue Nov 3, 2023 · 2 comments · Fixed by #572
Closed
Labels
bug Something isn't working

Comments

@technicalpickles
Copy link
Contributor

🔧 Summary

I'm working on moving us from another git hook tool to lefthook, so I've been testing how the git hooks get setup so I can make sure it works consistently. In doing that, I end up doing rm -r .git/hooks quite a bit.

I would have expected lefthook install to do that, but instead it exits silently and successfully. If I do lefthook install --force, it does not recreate the files

Lefthook version

1.5.2

Steps to reproduce

  • lefthook install
  • configure a simple pre-commit hook:
pre-commit:
  commands:
    echo:
      run: echo echo
  • lefthook install
  • rm .git/hooks/*
  • lefthook install

Expected results

For the last lefthook after the rm:

❯ lefthook install
sync hooks: ✔️ (pre-commit)

Actual results

❯ lefthook install

Possible Solution

I think it has to do with doing a checksum of the lefthook configuration. If I make any changes, it does seem to work as expected.

Logs / Screenshots

LEFTHOOK_VERBOSE=true git ...
@technicalpickles technicalpickles added the bug Something isn't working label Nov 3, 2023
@mrexox
Copy link
Member

mrexox commented Nov 3, 2023

Hey! Lefthook uses special hashsum to determine config file changes. It stores the hashsum to .git/info/lefthook.checksum. This is useful to skip re-installing hooks every time you execute the hook because this is how lefthook knows that your config file has changed or not.

But it makes sense to sync the hooks regardless of the changes in the config just because you run it manually. I'll try to fix this next week.

@technicalpickles
Copy link
Contributor Author

Two other datapoints:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants