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

pre-commit is skipped when commit contains only deleted files #919

Closed
wood-jp opened this issue Jan 10, 2025 · 0 comments · Fixed by #925
Closed

pre-commit is skipped when commit contains only deleted files #919

wood-jp opened this issue Jan 10, 2025 · 0 comments · Fixed by #925
Labels
bug Something isn't working

Comments

@wood-jp
Copy link

wood-jp commented Jan 10, 2025

🔧 Summary

The pre-commit hook is skipped when commit contains only deleted files.

Lefthook version

1.10.1

Steps to reproduce

  1. Have a pre-commit hook defined (eg echo "hello world")
pre-commit:
  commands:
    "hello":
      run: echo "hello world"
  1. Delete a file. Add to staged (no other changes).
  2. Commit change.

Expected results

Pre-commit hook should run.

Actual results

Pre-commit hook does not run.

Possible Solution

I tried using files as defined here

pre-commit:
  commands:
    "hello":
      files: git diff --staged --name-only
      run: echo "hello world"

But that did not change the outcome. Perhaps the pre-commit hook does not consider this option, but should.

Logs / Screenshots

╭───────────────────────────────────────╮
│ 🥊 lefthook v1.10.1  hook: pre-commit │
╰───────────────────────────────────────╯
sync hooks: ✔️ (pre-commit)
│  hello (skip) no files for inspection
                                      
@wood-jp wood-jp added the bug Something isn't working label Jan 10, 2025
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.

1 participant