Skip to content

Instantly share code, notes, and snippets.

@segiddins

segiddins/update_shared

Last active Nov 1, 2015
Embed
What would you like to do?
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