Created
December 14, 2018 21:57
-
-
Save gshaw/f622d4d5c9734267e8992ade117ae1d1 to your computer and use it in GitHub Desktop.
This file contains 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
#!/env/bin ruby | |
require "fileutils" | |
def process(dir) | |
puts "Analyzing #{dir}" | |
FileUtils.cd(dir) | |
puts "Finding outdated gems" | |
output = `bundle outdated --strict --only-explicit --parseable` | |
output.each_line do |line| | |
next if line.blank? | |
gem_name, newest_version, installed_version = parse_outdated_line(line) | |
next if gem_name.nil? | |
puts "Updating gem #{gem_name} to #{newest_version} from #{installed_version}" | |
upgrade_gem(gem_name) | |
end | |
end | |
def upgrade_gem(gem_name) | |
`git checkout master` | |
`git checkout -b update-gem-#{gem_name}` | |
`bundle update #{gem_name}` | |
`git add Gemfile.lock` | |
`git commit -m 'Update gem #{gem_name}'` | |
`git push` | |
`hub pull-request -m 'Update gem #{gem_name}'` | |
end | |
def parse_outdated_line(line) | |
/(.+) \(newest (.+), installed (.+)\)/.match(line)&.captures | |
end | |
process("/Users/gshaw/Sites/chitchats") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would there be value in adding the gem version in the PR desc / commit message?