21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/ossy/cli/changelogs/update.rb', line 21
def call(config_path:, message:)
attrs = YAML.safe_load(message)
target = YAML.load_file(config_path, permitted_classes: [Date])
version = attrs["version"] || target[0]["version"]
entry = target.detect { |e| e["version"].eql?(version) } || {}
release = Release.new(attrs.merge(version: version))
release.each do |type, logs|
(entry[type.to_s] ||= []).concat(logs).uniq!
end
entry.update(release.meta)
entry = KEYS.map { |key| [key, entry[key]] }.to_h
unless target.include?(entry)
target.unshift(entry.merge(release.meta))
end
File.write(config_path, YAML.dump(target))
end
|