diff --git a/scripts/github-changelog.cr b/scripts/github-changelog.cr index 4d48e580a2c8..cc2f24a1f365 100755 --- a/scripts/github-changelog.cr +++ b/scripts/github-changelog.cr @@ -271,18 +271,6 @@ record PullRequest, md = title.match(/\[fixup #(.\d+)/) || return md[1]?.try(&.to_i) end - - def clean_title - title.sub(/^\[?(?:#{type}|#{sub_topic})(?::|\]:?) /i, "").sub(/\s*\[Backport [^\]]+\]\s*/, "") - end - - def backported? - labels.any?(&.starts_with?("backport")) - end - - def backport? - title.includes?("[Backport ") - end end def query_milestone(api_token, repository, number) @@ -324,9 +312,8 @@ end milestone = query_milestone(api_token, repository, milestone) -class ChangelogEntry +struct ChangelogEntry getter pull_requests : Array(PullRequest) - property backported_from : PullRequest? def initialize(pr : PullRequest) @pull_requests = [pr] @@ -355,18 +342,13 @@ class ChangelogEntry if pr.deprecated? io << "**[deprecation]** " end - io << pr.clean_title + io << pr.title.sub(/^\[?(?:#{pr.type}|#{pr.sub_topic})(?::|\]:?) /i, "") io << " (" pull_requests.join(io, ", ") do |pr| pr.link_ref(io) end - if backported_from = self.backported_from - io << ", backported from " - backported_from.link_ref(io) - end - authors = collect_authors if authors.present? io << ", thanks " @@ -379,26 +361,15 @@ class ChangelogEntry def collect_authors authors = [] of String - - if backported_from = self.backported_from - if author = backported_from.author - authors << author - end - end - - pull_requests.each_with_index do |pr, i| - next if backported_from && i.zero? - + pull_requests.each do |pr| author = pr.author || next authors << author unless authors.includes?(author) end - authors end def print_ref_labels(io) pull_requests.each { |pr| print_ref_label(io, pr) } - backported_from.try { |pr| print_ref_label(io, pr) } end def print_ref_label(io, pr) @@ -409,7 +380,7 @@ class ChangelogEntry end entries = milestone.pull_requests.compact_map do |pr| - ChangelogEntry.new(pr) unless pr.fixup? || pr.backported? + ChangelogEntry.new(pr) unless pr.fixup? end milestone.pull_requests.each do |pr| @@ -423,17 +394,6 @@ milestone.pull_requests.each do |pr| end end -milestone.pull_requests.each do |pr| - next unless pr.backported? - - backport = entries.find { |entry| entry.pr.backport? && entry.pr.clean_title == pr.clean_title } - if backport - backport.backported_from = pr - else - STDERR.puts "Unresolved backport: #{pr.clean_title.inspect} (##{pr.number})" - end -end - sections = entries.group_by(&.pr.section) SECTION_TITLES = {