repo.rake 1.2 KB

123456789101112131415161718192021222324252627282930
  1. # frozen_string_literal: true
  2. namespace :repo do
  3. desc 'Generate the authors.md file'
  4. task :authors do
  5. file = File.open('AUTHORS.md', 'w')
  6. file << <<~HEADER
  7. Mastodon is available on [GitHub](https://github.com/tootsuite/mastodon)
  8. and provided thanks to the work of the following contributors:
  9. HEADER
  10. url = 'https://api.github.com/repos/tootsuite/mastodon/contributors?anon=1'
  11. HttpLog.config.compact_log = true
  12. while url.present?
  13. response = HTTP.get(url)
  14. contributors = Oj.load(response.body)
  15. contributors.each do |c|
  16. file << "* [#{c['login']}](#{c['html_url']})\n" if c['login']
  17. file << "* [#{c['name']}](mailto:#{c['email']})\n" if c['name']
  18. end
  19. url = LinkHeader.parse(response.headers['Link']).find_link(%w(rel next))&.href
  20. end
  21. file << <<~FOOTER
  22. 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.
  23. FOOTER
  24. end
  25. end