Skip to content

Instantly share code, notes, and snippets.

@fujimura
Last active December 18, 2015 23:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fujimura/5864323 to your computer and use it in GitHub Desktop.
Save fujimura/5864323 to your computer and use it in GitHub Desktop.
#! /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