Skip to content

Instantly share code, notes, and snippets.

@segiddins
Last active November 1, 2015 19:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save segiddins/ef99f37ef9dc0f9e1119 to your computer and use it in GitHub Desktop.
Update web repos' shared submodule
#!/usr/bin/env ruby
SHARED_PATH = 'shared'
Dir.glob('*segiddins.me').each do |repo|
Dir.chdir repo do
unless `command git status` =~ /working directory clean/
puts "The working directory for #{repo} is dirty"
end
pull = ''
shared_sha = ''
Dir.chdir SHARED_PATH do
puts "Updating the `shared` submodule for #{repo}"
pull = `command git checkout master && command git pull --ff-only`
shared_sha = `git rev-parse --short HEAD`
end
unless pull =~ /up to date/
commit_message = "[Shared] Update to segiddins/shared_assets@#{shared_sha}"
puts "Committing: #{commit_message}"
`command git commit -am '#{commit_message}'`
puts 'Pushing update'
`command git push`
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment