Skip to content

Commit 12c380a

Browse files
authored
Merge pull request #79 from OpenVoxProject/update_changelog_component_task
Don't add component table when there are no changes
2 parents b0baebd + 3c86ab4 commit 12c380a

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

tasks/vox.rake

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ task 'release:changelog_components', ['tag'] do |_, args|
121121
prev_data = data.values[1]
122122
new_data = data.values[0]
123123

124-
component_lines = ["\n**Component Changes:**\n", "| Component | Old Version | New Version |\n", "|-----------|-------------|-------------|\n"]
124+
header_lines = ["\n**Component Changes:**\n", "| Component | Old Version | New Version |\n", "|-----------|-------------|-------------|\n"]
125+
component_lines = []
125126
new_components = []
126127
data[args[:tag]]['components'].sort.each do |comp, ver|
127128
prev_ver = prev_data['components'][comp]
@@ -130,6 +131,7 @@ task 'release:changelog_components', ['tag'] do |_, args|
130131
new_components << comp if prev_ver.nil?
131132
component_lines << "| #{comp} | #{prev_data['components'][comp]} | #{ver} |\n"
132133
end
134+
component_lines = header_lines + component_lines unless component_lines.empty?
133135

134136
unless new_components.empty?
135137
component_lines << "\n**Project component additions:**\n"
@@ -141,10 +143,14 @@ task 'release:changelog_components', ['tag'] do |_, args|
141143
end
142144
end
143145

144-
content = File.read(changelog)
145-
new_content = content.sub('**Merged pull requests:**', "#{component_lines.join}\n**Merged pull requests:**")
146-
File.write(changelog, new_content)
147-
puts "Injected component change information into #{changelog} for tag #{args[:tag]}"
146+
if component_lines.empty?
147+
puts "No component changes detected for tag #{args[:tag]}"
148+
else
149+
content = File.read(changelog)
150+
new_content = content.sub('**Merged pull requests:**', "#{component_lines.join}\n**Merged pull requests:**")
151+
File.write(changelog, new_content)
152+
puts "Injected component change information into #{changelog} for tag #{args[:tag]}"
153+
end
148154
end
149155

150156
desc 'Prepare the changelog for a new release'

0 commit comments

Comments
 (0)