-
Notifications
You must be signed in to change notification settings - Fork 11
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
Option to skip/control which hook files are created during init #119
Comments
Is there any possibility to create a list of hooks to create? I would like to use only |
Sorry, I don't understand what you mean. Could you rephrase this question?
It would be possible with this feature although it hasn't been released. Even if it were released, you'd have to use the skip option (or manually created config file) to enumerate all the other hooks that you didn't want; it's more of an opt-out than an opt-in. rusty-hook's primary goal is to make git hooks easy so the users don't have to do or think about anything other than adding the commands to a config file, without having to run extra commands (or having to ask all your contributors to run commands) nor having to deal with the underlying git hooks yourselves. In order to accomplish this, yes, rust-hook establishes hook files, but it doesn't actually do any work unless you configure it as such. For example, if you only want to run something on |
Yes, indeed. My problem is that I have created this file first with configuration for only two hooks but In default configuration (without file - file created by Did I miss something in configuration, or it is not possible? Do you plan to release a new version with this skip option? |
Thank you for responding @wpater, however, I have to say that I don't feel like you really addressed the question. You'd already indicated that you don't want the hook files to be created, but you haven't explained why that's the case beyond sharing your There's a couple different styles of client side git hook tooling, and rusty-hook is absolutely in the style where creating all hook files is common and expected. This is done so that a single user can add a new hook command simply by checking in an update to the config file, and having that cascade to all users automatically (i.e. if you decide you want to introduce a new project-wide This is not without tradeoffs (like most choices in tech), but is an intentional decision to achieve the desired goals, and is always going to be our default behavior.
As I stated in my previous comment this feature hasn't been released. It's currently backed up behind other changes in source that would break backwards compatibility and thus the release is blocked. We will likely release it at some point once some of those blocking issues have been resolved, but it's not going to happen any time soon. For now, if you feel that strongly that the hook files shouldn't exist, then I'd suggest you consider alternative strategies/tooling, such as including hook file scripts in your repository with your own automation to copy or symlink them, or take a look at some of the alternative libs/tools we enumerate in our own Readme |
Ok, I understand you, thank you for your help. |
Absolutely! Thanks for giving rusty-hook a try and sharing your perspective. Will be sure to drop a note here whenever we manage to get the new feature deployed so feel free to subscribe to this issue if that's something you're interested in. |
Description
Add a feature that allows for controlling which hook files are instantiated
Value
Currently, the repo initialization process (triggered with either
rusty-hook init
or using compiling with rusty-hook as a dev dep) adds a hook file for all the supportable client side hooks to easily support user configurability. However, there are probably some advanced user scenarios where they'd like to control which hook files are/aren't created.For example, there are other Rust tools that support creating their own hook files (for example git-journal which supports commit message hooks) and we should support users that may want to use rusty-hook in conjunction with those others. There's also the potential for some users to want really fine grained control (create the
pre-commit
file but none of the others)Implementation Thoughts
I think the most common usage of this feature would be a skipping of one or two hook files (like
commit-msg
and perhapsprepare-commit-msg
) so my initial inclination would be to support this via a new config option skip list, for example:If there's sufficient demand down the road to support an opt-in type feature over an opt out, we could add an additional config at that time for an include/allow list and figure out precedence if and when we get there (implementing this as a skip/opt-out won't preclude doing more work in the future).
Currently, the init process that sets up the hook files in the repo just iterates through the full list of hooks:
rusty-hook/src/hooks.rs
Lines 75 to 80 in 39fbca3
(side note
create_hook_files
has a lot of duplication that could be consolidated into a separate closure or function)That could be updated pretty easily to accept a list of hook files to skip, and then use the subset of
HOOK_NAMES
that weren't skipped (I suppose technically the disjunctive union provided the skip list doesn't have any junk entries)Would then need to shuffle up the init order a bit to run the config creation check first, and then check for the
hook_file_skip_list
presence/value to pass along tosetup_hooks
function flowrusty-hook/src/rusty_hook.rs
Lines 10 to 36 in 39fbca3
The text was updated successfully, but these errors were encountered: