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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Replace faraday with httpx
Christophe Bliardcafadbbfbc5b
diff --git a/script/github_pr_errors b/script/github_pr_errorsindex 96dd7493c27..5579b112f8e 100755--- a/script/github_pr_errors+++ b/script/github_pr_errors@@ -11,8 +11,7 @@ require 'base64'require 'pathname'require 'pry'require 'yaml'-require 'faraday'-require 'faraday/follow_redirects'+require 'httpx'GITHUB_API_OPENPROJECT_PREFIX = 'https://api.github.com/repos/opf/openproject'.freezeGITHUB_HTML_OPENPROJECT_PREFIX = 'https://github.com/opf/openproject'.freeze@@ -147,35 +146,33 @@ def current_branch_name@current_branch_name ||= `git rev-parse --abbrev-ref HEAD`.stripend-def get_http(path)- url =- if path.start_with?('http')- path- else- "#{GITHUB_API_OPENPROJECT_PREFIX}/#{path}"- end+def github_url(path)+ if path.start_with?('http')+ path+ else+ "#{GITHUB_API_OPENPROJECT_PREFIX}/#{path}"+ end+end- say_verbose("HTTP GET #{url}")+def http+ HTTPX+ .plugin(:follow_redirects)+ .plugin(:basic_auth)+ .basic_auth(ENV.fetch('GITHUB_USERNAME'), ENV.fetch('GITHUB_TOKEN'))+end- conn = Faraday.new do |faraday|- faraday.response :follow_redirects # use Faraday::FollowRedirects::Middleware- faraday.response :raise_error # raise Faraday::Error on status code 4xx or 5xx- end+def get_http(path)+ url = github_url(path)+ say_verbose("HTTP GET #{url}")- response = conn.get(- url,- nil,- {- 'Authorization' => "Basic #{Base64::strict_encode64("#{ENV.fetch('GITHUB_USERNAME')}:#{ENV.fetch('GITHUB_TOKEN')}")}"- }- )+ response = http.get(url)say_verbose("HTTP Response #{response.status}")-- response.body-rescue Faraday::Error => e+ response.raise_for_status+ response.to_s+rescue HTTPX::HTTPError => ewarn error_details(e)- exit(1)+ exit 1rescue StandardError => ewarn "Failed to perform API request GET #{url}: #{e}"exit 1@@ -183,11 +180,10 @@ enddef error_details(error)response = error.response- response_body = JSON.parse(response[:body])+ response_body = response.jsonparts = []- parts << "Failed to perform API request #{response[:request][:method].upcase} #{response[:request][:url]}: " \- "#{error}"+ parts << "Failed to perform API request GET #{response.uri}: #{error}"parts << " #{response_body['message']}"parts << " See #{response_body['documentation_url']}"parts += error.backtrace.map { " #{_1}" }