Skip to content

Commit

Permalink
Add --markdown-output option to scripts/bors-stats.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
Anviking committed Feb 10, 2022
1 parent 2423a01 commit 424c0f9
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion scripts/bors-stats.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class BorsStats < Thor
:long_desc => "`--group #1 #2 #3` will replace #2 and #3 with #1."

desc "list", "list all failures"
method_option :markdown_output, :type => :boolean, :required => false, :desc => "Create markdown links to issues"
def list()
comments = fetch_comments_with_options options

Expand All @@ -84,7 +85,14 @@ def list()
n = k[:n]
title = tm.dig t, "title"
title = title.nil? ? "" : title
puts (bold(n.to_s) + " times (" + bold(failure_rate(n, nTot)) + ") " + yellow(t) + " " + bold(title))

tag_str =
if options[:markdown_output] and is_issue? t
then "[" + t + "](https://github.com/input-output-hk/cardano-wallet/issues/" + t.delete_prefix("#") + ")"
else yellow t
end

puts (bold(n.to_s) + " times (" + bold(failure_rate(n, nTot)) + ") " + tag_str + " " + bold(title))
end
end

Expand Down Expand Up @@ -664,6 +672,16 @@ def rewrite_tags(comments, title_map)
end
end

##
# >>> is_issue? "#0"
# true
#
## >>> is_issue? "0"
# false
def is_issue? t
true if t.start_with? "#" and Integer(t.delete_prefix "#") rescue false
end

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

Expand Down

0 comments on commit 424c0f9

Please sign in to comment.