I'm a big fan of hub, but I found myself wishing for the ability to use git hooks on pull-request messages the same way you can on commit messages with prepare-commit-msg
and commit-msg
hooks. People have been asking for hub to be able to do this for a while, but until that happens, here is a way you can do it yourself, right now.
To use this, just drop the script below into your $PATH
somewhere, and make sure you have your $EDITOR
environment variable set to whatever command runs your real editor, and then set your $GIT_EDITOR
environment variable to run the hub-editor
script.
The way this works is that when hub-editor
is invoked with a file named PULLREQ_EDITMSG
(which is the filename hub uses for editing pull requests) then it will run the prepare-pull-request-msg
and pull-request-msg
scripts from your .git/hooks
directory (if they exist and are executable). If hub-editor
is invoked with any other filename, then it just bails out to your real editor.
export EDITOR=vim
export GIT_EDITOR=hub-editor
hub pull-request