Skip to content

Commit

Permalink
Make tag an option
Browse files Browse the repository at this point in the history
  • Loading branch information
Anviking committed Jun 14, 2021
1 parent b9bb6a7 commit 6708f0b
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions scripts/bors-stats.rb
Expand Up @@ -283,8 +283,13 @@ def fetch_comments_with_options(options)
end
end
end

if options[:tag] then
comments = comments.filter {|x| x.tags.include? options[:tag] }
end

if options["fetch-system"] then
comments.each { |c| try_fetch_system c }
comments.each { |c| unless c.succeeded then try_fetch_system c end }
end

if options[:before] then
Expand Down Expand Up @@ -366,11 +371,6 @@ def write_logs(comment, tag, path, id, logs)
end

comments = fetch_comments_with_options options
# FIXME: De-duplicate this tag argument between the download and list commands.
unless tag.nil? then
comments[:filtered] = comments[:filtered].filter {|x| x.tags.include? ('#'+tag) }
end

comments[:filtered].each do |c|
c.links.each do |l|
if l.start_with? "https://buildkite" then
Expand Down Expand Up @@ -417,16 +417,14 @@ class BorsStats < Thor
class_option "force-refetch", :type => :boolean, :required => false, :default => false, :desc => "Fetch new data even if recent cache exists."
class_option :details, :type => :string, :required => false, :default => :auto, :desc => "Show details (true/false/auto)"
class_option :search, :type => :string, :required => false, :default => nil, :desc => "Filter on the bodyText of failures"
class_option :tag, :type => :string, :required => false, :desc => "Match this tag (e.g. #2040)"
class_option :annotate, :type => :array, :required => false, :desc => "Convert matches in comments into tags"
class_option :after, :type => :string, :required => false, :desc => "Only show failures after this date"
class_option :before, :type => :string, :required => false, :desc => "Only show failures before this date"

desc "list", "list all failures with optional filter (e.g. list 2292)"
def list(tag = nil)
desc "list", "list all failures"
def list()
comments = fetch_comments_with_options options
unless tag.nil? then
comments[:filtered] = comments[:filtered].filter {|x| x.tags.include? ('#'+tag) }
end

comments[:filtered].each do |c|
puts c.pretty(showDetails = options[:details])
Expand Down Expand Up @@ -454,8 +452,8 @@ def list(tag = nil)

desc "download-logs", "download all logs to the given dir"
method_option :dir, :type => :string, :required => false, :desc => "Directory for saving logs (default: tag being filtered on)"
def download_logs(tag = nil)
fetch_logs(tag, options)
def download_logs
fetch_logs(options)
end

default_task :list
Expand Down

0 comments on commit 6708f0b

Please sign in to comment.