Created
April 19, 2015 21:39
-
-
Save nberger/c69e8e7420e506d0b14a to your computer and use it in GitHub Desktop.
Pre-commit hook to enforce branch naming to play well with mercurial via git-remote-hg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def current_branch() | |
branches = `git branch --no-color`.split(/\n/) | |
branches.select{ |b| b =~ /\s*\*/ }.first.gsub(/[\*\s]/, "") | |
end | |
branch = current_branch | |
if branch != "master" && branch !~ /^branches\// | |
puts | |
puts " You are trying to commit on the *#{branch}* branch." | |
puts " To play well with hg, you should use branches named 'branches/...'" | |
puts | |
puts " If you really want to do this, force the commit by adding --no-verify to the command." | |
exit 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment