Skip to content

Instantly share code, notes, and snippets.

@jmeridth
Created December 23, 2009 04:59
Show Gist options
  • Save jmeridth/262319 to your computer and use it in GitHub Desktop.
Save jmeridth/262319 to your computer and use it in GitHub Desktop.
rails migrations post merge
#!/usr/bin/env ruby
`rake db:migrate && rake db:test:prepare` if `git diff HEAD^`.index("db/migrations")
@roychri
Copy link

roychri commented Sep 19, 2012

Nice hook script!

Wouldn't it be safer to do :

git diff --name-only  HEAD^

Since the db/migrations text could potentially appear in an actual diff output while not being the file that was changed?

What about this?

.index(/db\/migrations\//)

This would make sure not to catch any files that is elsewhere in the tree but contains this sequence of characters. Am I too paranoid? :)

I like the fact that it won't run the db:test:prepare if the db:migrate fails. :)

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