diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cli.rb | 8 | ||||
-rw-r--r-- | lib/mastodon/domains_cli.rb | 11 | ||||
-rw-r--r-- | lib/mastodon/version.rb | 2 | ||||
-rw-r--r-- | lib/tasks/repo.rake | 50 |
4 files changed, 59 insertions, 12 deletions
diff --git a/lib/cli.rb b/lib/cli.rb index a810c632a..6036adfbe 100644 --- a/lib/cli.rb +++ b/lib/cli.rb @@ -7,6 +7,7 @@ require_relative 'mastodon/accounts_cli' require_relative 'mastodon/feeds_cli' require_relative 'mastodon/settings_cli' require_relative 'mastodon/domains_cli' +require_relative 'mastodon/version' module Mastodon class CLI < Thor @@ -31,5 +32,12 @@ module Mastodon desc 'domains SUBCOMMAND ...ARGS', 'Manage account domains' subcommand 'domains', Mastodon::DomainsCLI + + map %w(--version -v) => :version + + desc 'version', 'Show version' + def version + say(Mastodon::Version.to_s) + end end end diff --git a/lib/mastodon/domains_cli.rb b/lib/mastodon/domains_cli.rb index be68ae84b..303b8a94a 100644 --- a/lib/mastodon/domains_cli.rb +++ b/lib/mastodon/domains_cli.rb @@ -140,15 +140,8 @@ module Mastodon end def stats_to_json(stats) - totals.each_key do |domain| - if totals[domain].is_a?(Hash) - totals[domain]['activity'] = stats[domain] - else - totals.delete(domain) - end - end - - say(Oj.dump(totals)) + stats.compact! + say(Oj.dump(stats)) end end end diff --git a/lib/mastodon/version.rb b/lib/mastodon/version.rb index 167a309ab..90514d78c 100644 --- a/lib/mastodon/version.rb +++ b/lib/mastodon/version.rb @@ -21,7 +21,7 @@ module Mastodon end def flags - 'rc1' + 'rc3' end def to_a diff --git a/lib/tasks/repo.rake b/lib/tasks/repo.rake index 367859e94..263cca84c 100644 --- a/lib/tasks/repo.rake +++ b/lib/tasks/repo.rake @@ -1,9 +1,9 @@ # frozen_string_literal: true namespace :repo do - desc 'Generate the authors.md file' + desc 'Generate the AUTHORS.md file' task :authors do - file = File.open('AUTHORS.md', 'w') + file = File.open(Rails.root.join('AUTHORS.md'), 'w') file << <<~HEADER Mastodon is available on [GitHub](https://github.com/tootsuite/mastodon) and provided thanks to the work of the following contributors: @@ -27,4 +27,50 @@ namespace :repo do This document is provided for informational purposes only. Since it is only updated once per release, the version you are looking at may be currently out of date. To see the full list of contributors, consider looking at the [git history](https://github.com/tootsuite/mastodon/graphs/contributors) instead. FOOTER end + + desc 'Replace pull requests with authors in the CHANGELOG.md file' + task :changelog do + path = Rails.root.join('CHANGELOG.md') + tmp = Tempfile.new + + HttpLog.config.compact_log = true + + begin + File.open(path, 'r') do |file| + file.each_line do |line| + if line.start_with?('-') + new_line = line.gsub(/#([[:digit:]]+)*/) do |pull_request_reference| + pull_request_number = pull_request_reference[1..-1] + response = nil + + loop do + response = HTTP.headers('Authorization' => "token #{ENV['GITHUB_API_TOKEN']}").get("https://api.github.com/repos/tootsuite/mastodon/pulls/#{pull_request_number}") + + if response.code == 403 + sleep_for = (response.headers['X-RateLimit-Reset'].to_i - Time.now.to_i).abs + puts "Sleeping for #{sleep_for} seconds to get over rate limit" + sleep sleep_for + else + break + end + end + + pull_request = Oj.load(response.to_s) + "[#{pull_request['user']['login']}](#{pull_request['html_url']})" + end + + tmp.puts new_line + else + tmp.puts line + end + end + end + + tmp.close + FileUtils.mv(tmp.path, path) + ensure + tmp.close + tmp.unlink + end + end end |