Skip to content

Commit

Permalink
Add "re-write rules" for bors comments
Browse files Browse the repository at this point in the history
This gives us a fairly easy way to close specific tickets in favor of a
more general one, without having to edit the corresponding bors-comments.

This is done by writing e.g. "(Instance of #2)" for issue #1, if you
want re-annotate failures from #1 as really being from #2.
  • Loading branch information
Anviking committed Aug 27, 2021
1 parent 9e71c1c commit 6047e28
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/bors-stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,11 @@ def failure_rate(n, nTot)
def fetch_comments_with_options(options)
comments = fetch_comments(target = options[:count], nil, options["force-refetch"]).sort_by { |x| event_date x }

# Fetching the title map here ourselves is suboptimal, but
# since we have on-disk caching is should be ok.
tm = fetch_gh_ticket_titlemap options
rewrite_tags(comments, tm)

if options[:search] then
comments = comments.filter {|x| x.bodyText.include? options[:search] }
end
Expand Down Expand Up @@ -638,6 +643,27 @@ def debug_trace(msg)
end
end

# Re-writes the tags of the provided comments list in-place,
# according to user-provided annotations in the issue titles.
#
# Annotations:
# "(Instance of #2) ..." - replace tag with #2
def rewrite_tags(comments, title_map)
rewrite_map = {}
title_map.each do |k,v|
new_tag = v["title"].scan(/^\(Instance of (#[\d]+)\)/).to_a.map { |x| x[0] }.first
if new_tag then
rewrite_map[k] = new_tag
end
end
comments.each do |c|
c.tags = c.tags.map do |t|
t2 = rewrite_map[t]
if t2 then t2 else t end
end
end
end

######################################################################
# ANSI color code helpers

Expand Down

0 comments on commit 6047e28

Please sign in to comment.