mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-08 08:44:27 +00:00
Change output format of repo:changelog
task (#31546)
This commit is contained in:
parent
62be0234d5
commit
c493689e84
|
@ -49,24 +49,32 @@ namespace :repo do
|
||||||
File.open(path, 'r') do |file|
|
File.open(path, 'r') do |file|
|
||||||
file.each_line do |line|
|
file.each_line do |line|
|
||||||
if line.start_with?('-')
|
if line.start_with?('-')
|
||||||
new_line = line.gsub(/[(]#([[:digit:]]+)[)]\Z/) do |pull_request_reference|
|
new_line = line.gsub(/\(#([[:digit:]]+)(, #([[:digit:]]+))*\)\Z/) do |pull_requests_string|
|
||||||
pull_request_number = pull_request_reference[2..-2]
|
pull_requests = pull_requests_string[1...-1].split(',').map { |pr_id| pr_id.strip[1...] }
|
||||||
response = nil
|
response = nil
|
||||||
|
|
||||||
loop do
|
authors = pull_requests.map do |pull_request_number|
|
||||||
response = HTTP.headers('Authorization' => "token #{ENV['GITHUB_API_TOKEN']}").get("https://api.github.com/repos/#{REPOSITORY_NAME}/pulls/#{pull_request_number}")
|
response = nil
|
||||||
|
|
||||||
if response.code == 403
|
loop do
|
||||||
sleep_for = (response.headers['X-RateLimit-Reset'].to_i - Time.now.to_i).abs
|
response = HTTP.headers('Authorization' => "token #{ENV['GITHUB_API_TOKEN']}").get("https://api.github.com/repos/#{REPOSITORY_NAME}/pulls/#{pull_request_number}")
|
||||||
puts "Sleeping for #{sleep_for} seconds to get over rate limit"
|
|
||||||
sleep sleep_for
|
if response.code == 403
|
||||||
else
|
sleep_for = (response.headers['X-RateLimit-Reset'].to_i - Time.now.to_i).abs
|
||||||
break
|
puts "Sleeping for #{sleep_for} seconds to get over rate limit"
|
||||||
|
sleep sleep_for
|
||||||
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
pull_request = Oj.load(response.to_s)
|
||||||
|
pull_request['user']['login']
|
||||||
end
|
end
|
||||||
|
|
||||||
pull_request = Oj.load(response.to_s)
|
authors.sort!.uniq!
|
||||||
"([#{pull_request['user']['login']}](#{pull_request['html_url']}))"
|
|
||||||
|
"(#{pull_requests.map { |pr| "##{pr}" }.to_sentence} by #{authors.map { |author| "@#{author}" }.to_sentence})"
|
||||||
end
|
end
|
||||||
|
|
||||||
tmp.puts new_line
|
tmp.puts new_line
|
||||||
|
|
Loading…
Reference in a new issue