Created
January 6, 2015 02:49
-
-
Save fujimura/87ce58d7bfa7dadefea2 to your computer and use it in GitHub Desktop.
post-checkout hook to prevent from checking out master
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 | |
# colorization | |
def colorize(color_code) | |
"\e[#{color_code}m#{self}\e[0m" | |
end | |
def red | |
colorize(31) | |
end | |
end | |
current_branch = `git branch | grep '*' | awk '{ print \$2 }'`.chomp | |
if current_branch == 'master' | |
`git checkout develop` | |
puts "You are trying to checkout `master`, but our default branch is `develop`. Now this post-commit checked out `develop` to not break `master`.".red | |
puts "If you really want to checkout `master`, please modify this file(#{File.expand_path(__FILE__)}).".red | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment