Skip to content

Instantly share code, notes, and snippets.

@scalp42
Forked from sdhull/pre-commit
Created April 17, 2012 23:39
Show Gist options
  • Save scalp42/2409932 to your computer and use it in GitHub Desktop.
Save scalp42/2409932 to your computer and use it in GitHub Desktop.
.git/hooks/pre-commit
#!/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