Skip to content

Instantly share code, notes, and snippets.

@fujimura
Last active Dec 18, 2015
Embed
What would you like to do?
#! /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