-
Notifications
You must be signed in to change notification settings - Fork 612
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
[rush] Add support for git hooks #916
Conversation
@nchlswhttkr cool, thanks for making this PR! :-) My main feedback is that this should probably be a repo-wide configuration, rather than a command-line option. At least, in the use cases that I've observed, the repo maintainer would want to set this up for all developers (e.g. to normalize their code using Prettier), rather than it being an "opt-in" feature that happens when they install. One way to do that would be via the rush.json config file. Although in the original issue it occurred to me that the presence of the common/git-hooks/ folder might be sufficient. #Resolved |
I agree with that. I think having a For now, I can change to logic to run by default and log when it detects and copies over any new/updated git hooks. #Resolved |
Yes, I think this makes sense, for a couple reasons:
|
One edge case would be if NO hooks are registered with Rush. In this case, it might be safer to do nothing, rather than deleting all the Git hooks. (?) #Resolved |
Hooks are now installed when the /common/git-hooks folder is non-empty. Any hooks already installed will be deleted before new hooks are added.
…hlswhttkr/git-hooks
I've updated the PR accordingly, for now it clears any existing hooks before doing an install. Having the For now, Rush is just providing a central location to store and manage repo-wide git hooks. If we want to extend beyond this with more configuration options, that discussion can occur another time when we know the requirements better. #Resolved |
Hey @nchlswhttkr, sorry it took a while to follow up. We wanted someone to test it out in a real repo before we merge the feature. I just chatted with @natalieethell who is going to give this a try in the office-ui-fabric-react project, which uses Git hooks. Then we'll finally merge it. Thanks for your patience! #Resolved |
No worries 👌 #Resolved |
Just finished up trying this out in the office-ui-fabric-react project, and it seems to work as expected. Everything in Additionally, if |
Awesome, thanks a bunch @natalieethell ! I'll merge this and include it with the next Rush release #Resolved |
… of the folder is not determined by Git
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nchlswhttkr FYI this was published as part of Rush 5.5.1 I also wrote some documentation here: https://rushjs.io/pages/maintainer/git_hooks/ Thanks again for implementing this! |
You're welcome, have a good one! |
Resolves #821
Feedback on this would be welcome, I'm not sure how to test this during runtime.
At the moment, I'm just copying over any files in
common/git-hooks
to the git config, so stricter rules could be applied if needed.Is there any need to worry about clearing the
.git/hooks
directory before writing to get rid of outdated scripts?FileSystem.copyFile
should overwrite automatically, but that won't get rid of old files if a replacement does not exist.Happy hacktoberfest!