8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/gem_changes/gemfile.rb', line 8
module_function def changes(git:)
diff = git.diff_for_file("Gemfile.lock")
return [] if diff.nil?
added = {}
diff.patch.scan(ADDITION_REGEX).each do |match|
added[match[0]] = match[1]
end
removed = {}
diff.patch.scan(REMOVAL_REGEX).each do |match|
removed[match[0]] = match[1]
end
all_gems = added.keys | removed.keys
all_gems.map do |gem_name|
gem = Gem.new(name: gem_name)
Change.new(gem:, from: removed[gem_name], to: added[gem_name])
end
end
|