Skip to content

Instantly share code, notes, and snippets.

@goncalossilva
Created May 1, 2012 16:08
Show Gist options
  • Save goncalossilva/2569201 to your computer and use it in GitHub Desktop.
Save goncalossilva/2569201 to your computer and use it in GitHub Desktop.
Don't commit conflicts
#!/usr/bin/env ruby
`git diff-index --name-status HEAD`.split("\n").each do
|status_with_filename|
status, filename = status_with_filename.split(/\s+/)
next if status == 'D'
File.open(filename) do |file|
while line = file.gets
if line.include?("<<<<<<<") || line.include?(">>>>>>>")
puts "ERROR: #{filename} has unresolved conflicts"
puts "Continue (type 'yes')?"
if gets.chomp == "yes"
next
else
exit(1)
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment