diff options
author | John Keiser <john@johnkeiser.com> | 2016-08-08 11:31:54 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2016-08-10 14:50:44 -0700 |
commit | 9860fd5e3edbda739670a2d24ccb1c9845a0cbf1 (patch) | |
tree | e3bc947e2725e53b9978620bd8f88ce75f80cb11 /tasks | |
parent | f447166308858df33a728aba0b59fc80852c3c16 (diff) | |
download | chef-9860fd5e3edbda739670a2d24ccb1c9845a0cbf1.tar.gz |
Add release notes and gem version diff generator
Diffstat (limited to 'tasks')
-rwxr-xr-x | tasks/bin/gem-version-diff | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tasks/bin/gem-version-diff b/tasks/bin/gem-version-diff new file mode 100755 index 0000000000..617402d4e6 --- /dev/null +++ b/tasks/bin/gem-version-diff @@ -0,0 +1,37 @@ +#!/usr/bin/env ruby + +require_relative "../../version_policy" + +old_version, new_version = ARGV[0..1] + +require "set" +ENV["BUNDLE_WITHOUT"] = INSTALL_WITHOUT_GROUPS.join(":") +relevant_gems = Set.new +`bundle list`.each_line do |line| + next unless line =~ /^ \* (\S+)/ + relevant_gems.add($1) +end + +old_gems = {} +old_file = `git show #{old_version}:Gemfile.lock` +old_file.each_line do |line| + next unless line =~ /^ (\S+) \(([^\)]+)\)$/ + next unless relevant_gems.include?($1) + old_gems[$1] = $2 +end + +new_gems = {} +new_file = `git show #{new_version}:Gemfile.lock` +new_file.each_line do |line| + next unless line =~ /^ (\S+) \(([^\)]+)\)$/ + next unless relevant_gems.include?($1) + new_gems[$1] = $2 +end + +modified_gems = (old_gems.keys & new_gems.keys).sort.select { |name| new_gems[name] != old_gems[name] }.map { |name| "#{name} - #{new_gems[name]} (was #{old_gems[name]})" } +removed_gems = (old_gems.keys - new_gems.keys).sort.map { |name| "#{name} - #{old_gems[name]}" } +added_gems = (new_gems.keys - old_gems.keys).sort.map { |name| "#{name} - #{new_gems[name]}" } + +puts "MODIFIED:\n#{modified_gems.join("\n")}" if modified_gems.any? +puts "\nADDED:\n#{added_gems.join("\n")}" if added_gems.any? +puts "\nREMOVED:\n#{removed_gems.join("\n")}" if removed_gems.any? |