Last active
December 18, 2015 23:49
-
-
Save fujimura/5864323 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# Pull all directory under current directory, if it's on master, has no local changes, can be pulled fast-forward. | |
def git_repo? | |
`git status`.chomp !~ /Not a git repository/ | |
end | |
def not_changed? | |
`git status -s`.chomp.empty? | |
end | |
def master? | |
# .gitconfig | |
# current-branch = "!sh -c \"git branch | grep '*' | awk '{ print \\$2 }' \"" | |
`git current-branch`.chomp == 'master' | |
end | |
Dir['./*'].select {|d| File.directory? d }.each do |d| | |
Dir.chdir d do | |
if git_repo? && not_changed? && master? | |
puts `git pull --ff-only` | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment