Skip to content

Instantly share code, notes, and snippets.

@flyerhzm
Created November 11, 2011 05:35
Show Gist options
  • Save flyerhzm/1357284 to your computer and use it in GitHub Desktop.
Save flyerhzm/1357284 to your computer and use it in GitHub Desktop.
git commit-msg hook to promise not committing conflicts
#!/usr/bin/env ruby
`git diff-index --name-only --cached HEAD`.split("\n").each do |filename|
File.open(filename) do |file|
while line = file.gets
if line.include?("<<<<<<<") || line.include?(">>>>>>>")
puts "ERROR: #{filename} is conflict"
exit(1)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment