-
Notifications
You must be signed in to change notification settings - Fork 280
Add GitLfs post-checkout, post-commit and post-merge hooks #543
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
Conversation
|
Not sure how to fix the following type of error: |
sds
left a comment
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.
Thanks for the pull request, @proinsias. I think you've done more work than what's necessary, and can simplify substantially.
| "was not found on your path.\nIf you no longer wish to use Git LFS, " \ | ||
| 'disable this hook by removing or setting \'enabled: false\' for GitLFS ' \ | ||
| 'hook in your .overcommit.yml file' | ||
| end |
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.
You shouldn't need to perform this check explicitly. Simply specify the required_executable option in the hook configuration.
I can see that you're trying to provide a bit extra information, but my hope is that the existing error message is pretty straightforward, and that anyone working with a repo using LFS knows what Git LFS is.
| 'hook in your .overcommit.yml file' | ||
| end | ||
|
|
||
| result = execute(['git', 'lfs', 'post-checkout', previous_head, new_head, branch_checkout?]) |
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.
Have you read the documentation for adding existing Git hooks? If you are just executing a ready-made hook, you don't need to write any Ruby code.
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.
Yes. I've had the following two issues with this approach before, and so thought it would be helpful to have specific hooks (a la the git-lfs pre-push ones) in overcommit:
I believe the required_executable has to checked into git, and so:
- I have to put the hook manually in every repo.
- I can't use this approach for shared repos at work, where I'm the only one using
overcommit.
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.
Thanks for clarifying, @proinsias. I think when we added that restriction many years ago we were being overly cautious. Thinking on this, seems reasonable to allow ad hoc hooks to reference executables that are in your PATH.
The danger comes from someone creating/modifying a hook that changes the command to rm -rf / or similar, but this should be caught by the hook signing logic for the hook's configuration itself.
I'm open to a PR that modifies the HookSigner to support this. Otherwise I'll get to it when I can. Thanks!
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.
Hey @proinsias, I took a stab at adding support for arbitrary commands as ad hoc hooks hooks in 5a0a4ec.
Could you try rebasing and rebuilding these hooks using that? Would love to get your feedback. Thanks!
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.
Looking into this now!
|
@sds – looks good to me! |
#479 added the pre-push hook for
git-lfs.This PR adds the additional hooks that are now available with
git-lfs.