Skip to content

Instantly share code, notes, and snippets.

@sdhull
Created April 17, 2012 23:36
Show Gist options
  • Save sdhull/2409918 to your computer and use it in GitHub Desktop.
Save sdhull/2409918 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 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
@jrichardlai
Copy link

yeah!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment