Last active
August 29, 2015 14:05
-
-
Save peteygao/b8c5b9d70a2e4a8a486b to your computer and use it in GitHub Desktop.
Using git hook to notify us when schema.rb and Gemfile changes after a pull
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
#!/usr/bin/env ruby | |
class String | |
# Give our output some colour option :D! | |
def black; "\033[30m#{self}\033[0m" end | |
def red; "\033[31m#{self}\033[0m" end | |
def green; "\033[32m#{self}\033[0m" end | |
def blue; "\033[34m#{self}\033[0m" end | |
def yellow; "\033[33m#{self}\033[0m" end | |
def magenta; "\033[35m#{self}\033[0m" end | |
def cyan; "\033[36m#{self}\033[0m" end | |
def gray; "\033[37m#{self}\033[0m" end | |
end | |
changed_files = `git diff-index --cached --name-only HEAD~` | |
if changed_files.include? 'Gemfile' | |
puts 'Gemfile has changed, you might need to run `bundle install`'.yellow | |
end | |
if changed_files.include? 'schema.rb' | |
puts 'schema.rb has changed, you might need to run `rake db:migrate`'.red | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment