Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add verbose output to script/github_pr_errors

Christophe Bliard547e490f1308
diff --git a/script/github_pr_errors b/script/github_pr_errors
index 264f7eacebc..3bd4793ac76 100755
--- a/script/github_pr_errors
+++ b/script/github_pr_errors
@@ -29,7 +29,8 @@ class Options
display_rerun_info: false,
failed_jobs_logs: [],
no_cache: false,
- run_id: nil
+ run_id: nil,
+ verbose: false
}.freeze
BANNER = <<~BANNER.freeze
@@ -97,6 +98,11 @@ class Options
puts parser
exit
end
+
+ parser.on("-v", "--verbose",
+ "Print more information, mostly useful for debugging") do |value|
+ options[:verbose] = true
+ end
end
opt_parser.parse!
options
@@ -104,6 +110,12 @@ class Options
end
end
+def say_verbose(text)
+ return unless Options.verbose
+
+ warn "| #{text}"
+end
+
# Returns current branch
def current_branch_name
@current_branch_name ||= `git rev-parse --abbrev-ref HEAD`.strip
@@ -117,6 +129,7 @@ def get_http(path)
"#{GITHUB_API_OPENPROJECT_PREFIX}/#{path}"
end
+ say_verbose("HTTP GET #{url}")
response = RestClient::Request.new(
method: :get,
url:,
@@ -124,6 +137,8 @@ def get_http(path)
password: ENV.fetch('GITHUB_TOKEN')
).execute
+ say_verbose("HTTP Response #{response.code}")
+
response.to_str
rescue RestClient::ExceptionWithResponse => e
warn error_details(e)
@@ -179,10 +194,12 @@ def cached(unique_name)
cached_file = RAILS_ROOT.join("tmp/github_pr_errors/#{unique_name}")
if cached_file.file?
+ say_verbose("Reading from cached file #{cached_file}")
content = cached_file.read
content.start_with?("---") ? YAML::load(content) : content
else
content = yield
+ say_verbose("Writing to cached file #{cached_file}")
cached_file.dirname.mkpath
cached_file.write(content.is_a?(String) ? content : YAML::dump(content))
content