Created
April 17, 2012 23:36
-
-
Save sdhull/2409918 to your computer and use it in GitHub Desktop.
.git/hooks/pre-commit
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 | |
file_names = `git diff-index --cached -Sdebugger --name-only HEAD` | |
file_names += `git diff-index --cached -Ssave_and_open_page --name-only HEAD` | |
file_names = file_names.strip | |
if file_names != "" | |
puts "The following files have 'debugger' or 'save_and_open_page' statements in them: " | |
puts file_names | |
raise "Please complete your merge prior to committing" unless ENV["FORCE"] | |
end | |
file_names = `git diff-index --cached -S'<<<<<<<' --name-only HEAD`.chomp.split | |
file_names += `git diff-index --cached -S'=======' --name-only HEAD`.chomp.split | |
file_names += `git diff-index --cached -S'>>>>>>>' --name-only HEAD`.chomp.split | |
file_names = file_names.uniq.join("\n") | |
if file_names != "" | |
puts "The following files have incomplete merges: " | |
puts file_names | |
raise "Please complete your merge prior to committing" unless ENV["FORCE"] | |
end |
so do FORCE=true git commit -m 'Committing a debugger!'
yeah!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Edited so that you can force a commit to happen if you (for instance) remove a debugger and commit that, or if you just really really want to commit a debugger, save_and_open_page, or unmerged file.