-
-
Save bobmaerten/efa460e038418479359f45877d6501fc to your computer and use it in GitHub Desktop.
Automatically resolve Git merge conflicts in Rails schema.rb by picking the most recent date in the conflict (works with Rails 6 and recent versions of Git). The following files should be in your home ~ directory.
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
db/schema.rb merge=railsschema |
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
[merge "railsschema"] | |
name = Newer Rails schema version | |
driver = "ruby -e '\n\ | |
system %(git), %(merge-file), %(--marker-size=%L), %(%A), %(%O), %(%B)\n\ | |
b = File.read(%(%A))\n\ | |
b.sub!(\\A<+ .*\\nActiveRecord::Schema.define.version: ([_0-9]+). do\\n\\|+ .*\\nActiveRecord::Schema.define.version: ([_0-9]+). do\\n=+\\nActiveRecord::Schema.define.version: ([_0-9]+). do\\n>+ .*\\z) do\n\ | |
%(ActiveRecord::Schema.define(version: #{[$1, $2, $3].max}) do)\n\ | |
end\n\ | |
File.open(%(%A), %(w)) {|f| f.write(b)}\n\ | |
exit 1 if b.include?(%(<)*%L)'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment