-
Notifications
You must be signed in to change notification settings - Fork 280
Add support for pre-push hooks #154
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
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.
ARGF has some additional semantics that aren't necessary here. I'd like it if we just read directly from STDIN.
However, I'd like to take this request a step further by having us inject STDIN as a dependency to the hook context itself. Then we could define the input_lines helper on Overcommit::HookContext::Base and reuse it in post-rewrite. To be clear, I'd like to see https://github.com/brigade/overcommit/blob/master/template-dir/hooks/overcommit-hook#L48 become:
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)...and have the various HookContext classes take an additional argument input containing the input stream. I think this will make testing cleaner (it forces us to be explicit about what we're expecting in the input stream, even for hooks that don't read from STDIN).
Overcommit will automatically update itself when overcommit-hook changes, so this shouldn't have any negative consequences for users when upgrading.
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.
That's how I initially implemented it, but I didn't want this PR to grow beyond its intended scope. But I agree that constructor injection is the way to go here.
|
Thanks! |
Pre-push hooks are passed the name and url of the remote as arguments, and STDIN contains info about pushed commits, one per line, in the format
local_ref local_sha1 remote_ref remote_sha1.