Skip to content

Commit

Permalink
Refactor GitHub changelog generator print special infra (#14795)
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Aug 8, 2024
1 parent edce0a3 commit 2a8ced5
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions scripts/github-changelog.cr
Original file line number Diff line number Diff line change
Expand Up @@ -367,32 +367,37 @@ puts
puts "[#{milestone.title}]: https://github.com/#{repository}/releases/#{milestone.title}"
puts

def print_items(prs)
prs.each do |pr|
puts "- #{pr}"
end
puts

prs.each(&.print_ref_label(STDOUT))
puts
end

SECTION_TITLES.each do |id, title|
prs = sections[id]? || next
puts "### #{title}"
puts

topics = prs.group_by(&.primary_topic)
if id == "infra"
prs.sort_by!(&.infra_sort_tuple)
print_items prs
else
topics = prs.group_by(&.primary_topic)

topic_titles = topics.keys.sort_by! { |k| TOPIC_ORDER.index(k) || Int32::MAX }
topic_titles = topics.keys.sort_by! { |k| TOPIC_ORDER.index(k) || Int32::MAX }

topic_titles.each do |topic_title|
topic_prs = topics[topic_title]? || next
topic_titles.each do |topic_title|
topic_prs = topics[topic_title]? || next

if id == "infra"
topic_prs.sort_by!(&.infra_sort_tuple)
else
topic_prs.sort!
puts "#### #{topic_title}"
puts
end

topic_prs.each do |pr|
puts "- #{pr}"
topic_prs.sort!
print_items topic_prs
end
puts

topic_prs.each(&.print_ref_label(STDOUT))
puts
end
end

0 comments on commit 2a8ced5

Please sign in to comment.