-
-
Save scalp42/2409932 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 remove this stuff prior to committing" | |
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" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment