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

Does not work correctly if there are multiple excludes #781

Closed
pvcresin opened this issue Jul 24, 2024 · 2 comments · Fixed by #782
Closed

Does not work correctly if there are multiple excludes #781

pvcresin opened this issue Jul 24, 2024 · 2 comments · Fixed by #782
Labels
bug Something isn't working

Comments

@pvcresin
Copy link

pvcresin commented Jul 24, 2024

🔧 Summary

As the title says.

(Thank you very much for support of multiple exclude!)

Lefthook version

1.7.5 d7ae5f7

Steps to reproduce

Repository: https://github.com/pvcresin/lefthook-exclude-test

package.json

{
  "devDependencies": {
    "lefthook": "^1.7.5",
    "prettier": "^3.3.3"
  }
}

lefthook.yml

---
pre-commit:
  parallel: true
  commands:
    format:
      glob: "*.js"
      # exclude: "b.js|c.js" # worked correctly
      exclude:
        - b.js
        - c.js
      run: |
        echo {staged_files}
        npx prettier --write {staged_files}
      stage_fixed: true

If I try to commit a.js, b.js, c.js, I want to format only a.js by prettier.

exclude: “b.js|c.js” # worked correctly.
exclude: # did not seem to work correctly.
  - b.js
  - c.js

Expected results

exclude:
  - b.js
  - c.js

If I try to commit a.js, b.js, c.js, only a.js is formatted

Actual results

exclude:
  - b.js
  - c.js

If I try to commit a.js, b.js, c.js, all a.js, b.js, c.js are formatted. 😢

Possible Solution

It might be more correct to append if v did not match all globs

https://github.com/evilmartians/lefthook/pull/777/files#diff-95baf66be56f3f284ac7a6f45870dbff51131728ff6cfa163e9eac9721229697R94-R97

Logs / Screenshots

LEFTHOOK_VERBOSE=true git ...
@pvcresin pvcresin added the bug Something isn't working label Jul 24, 2024
@pvcresin
Copy link
Author

@mrexox seems to know more about it.

@mrexox
Copy link
Member

mrexox commented Jul 24, 2024

Hey @pvcresin! Thank you for submitting a bug. The fix will be ready soon

@mrexox mrexox mentioned this issue Jul 24, 2024
2 tasks
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