Created
December 14, 2018 21:57
-
-
Save gshaw/f622d4d5c9734267e8992ade117ae1d1 to your computer and use it in GitHub Desktop.
Revisions
-
gshaw created this gist
Dec 14, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ #!/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")