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

Global path exclude #593

Open
sanmai-NL opened this issue Dec 11, 2023 · 0 comments
Open

Global path exclude #593

sanmai-NL opened this issue Dec 11, 2023 · 0 comments
Labels
feature request A new lefthook feature description

Comments

@sanmai-NL
Copy link
Contributor

sanmai-NL commented Dec 11, 2023

⚡ Summary

In monorepos, sometimes the CI/CD jobs running Lefthook must be specific to particular products, each included in that repo. Currently, Lefthook has no convenient way to globally include or exclude files based on criteria other than what's staged.

Value

Also, when CI/CD jobs run on the default branch, for example, Lefthook may be invoked with --all-files. Jobs specific to a product and running on non-default branches should only include files related to that product, based on which files were staged/committed.

Behavior and configuration changes

Support --exclude CLI parameter(s) that filter all file lists that Lefthook uses, even with --all-files, {files} or {staged_files}.

Design and alternatives

One feature, perhaps larger epic, is to support parsing CODEOWNERS. It's possible to create sections in there that cover one or more globs. These sections could constitute products in a monorepo. Moreover, this adds a lot of value to give specific feedback to individual developers based on their role or product responsibility, when using Lefthook as local Git hook.

Alternatively, irrelevant files/directories could be deleted or be made inaccessible from the filesystem in the CI job, before launching Lefthook. However, that leads to unstaged changes that may influence some common commands (e.g., a command to forbid unstaged changes pre-push). Sometimes files are shared between products, so they can't be removed surgically. Also, some tools, like Prettier report failure when provided with globs to paths it can't read.

Also alternatively, the Lefthook configuration file(s) could be mutated in the CI job prior to Lefthook execution, so that files are excluded somehow. That is hard to maintain and sometimes hard to implement, when using a mixture of {files}, {staged_files} and different commands etc.

@sanmai-NL sanmai-NL added the feature request A new lefthook feature description label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A new lefthook feature description
Projects
None yet
Development

No branches or pull requests

1 participant