2024-03-21 22:10:12 -07:00
|
|
|
# typed: strict
|
2021-02-04 17:00:50 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-03-21 22:10:12 -07:00
|
|
|
require "abstract_command"
|
2021-02-04 17:00:50 +05:30
|
|
|
require "utils/github"
|
2022-11-08 20:36:10 +09:00
|
|
|
require "manpages"
|
2024-01-31 20:00:54 -08:00
|
|
|
require "system_command"
|
2021-02-04 17:00:50 +05:30
|
|
|
|
|
|
|
module Homebrew
|
2024-03-21 22:10:12 -07:00
|
|
|
module DevCmd
|
|
|
|
class UpdateMaintainers < AbstractCommand
|
|
|
|
include SystemCommand::Mixin
|
2021-02-04 17:00:50 +05:30
|
|
|
|
2024-03-21 22:10:12 -07:00
|
|
|
cmd_args do
|
|
|
|
description <<~EOS
|
|
|
|
Update the list of maintainers in the `Homebrew/brew` README.
|
|
|
|
EOS
|
2021-02-04 17:00:50 +05:30
|
|
|
|
2024-03-21 22:10:12 -07:00
|
|
|
named_args :none
|
|
|
|
end
|
2021-02-04 17:00:50 +05:30
|
|
|
|
2024-03-21 22:10:12 -07:00
|
|
|
sig { override.void }
|
|
|
|
def run
|
|
|
|
# We assume that only public members wish to be included in the README
|
|
|
|
public_members = GitHub.public_member_usernames("Homebrew")
|
|
|
|
maintainers = GitHub.members_by_team("Homebrew", "maintainers")
|
2021-02-04 17:00:50 +05:30
|
|
|
|
2024-03-21 22:10:12 -07:00
|
|
|
members = {
|
|
|
|
plc: GitHub.members_by_team("Homebrew", "plc"),
|
|
|
|
tsc: GitHub.members_by_team("Homebrew", "tsc"),
|
|
|
|
maintainers:,
|
|
|
|
}
|
2021-02-04 17:00:50 +05:30
|
|
|
|
2024-03-21 22:10:12 -07:00
|
|
|
sentences = {}
|
|
|
|
members.each do |group, hash|
|
|
|
|
hash.replace(hash.slice(*public_members))
|
|
|
|
hash.each { |login, name| hash[login] = "[#{name}](https://github.com/#{login})" }
|
|
|
|
sentences[group] = hash.values.sort.to_sentence
|
|
|
|
end
|
2021-02-04 17:00:50 +05:30
|
|
|
|
2024-03-21 22:10:12 -07:00
|
|
|
readme = HOMEBREW_REPOSITORY/"README.md"
|
2021-02-04 17:00:50 +05:30
|
|
|
|
2024-03-21 22:10:12 -07:00
|
|
|
content = readme.read
|
|
|
|
content.gsub!(/(Homebrew's \[Project Leadership Committee.*) is .*\./,
|
|
|
|
"\\1 is #{sentences[:plc]}.")
|
|
|
|
content.gsub!(/(Homebrew's \[Technical Steering Committee.*) is .*\./,
|
|
|
|
"\\1 is #{sentences[:tsc]}.")
|
|
|
|
content.gsub!(/(Homebrew's maintainers are).*\./,
|
|
|
|
"\\1 #{sentences[:maintainers]}.")
|
2021-02-04 17:00:50 +05:30
|
|
|
|
2024-03-21 22:10:12 -07:00
|
|
|
File.write(readme, content)
|
2021-02-04 17:00:50 +05:30
|
|
|
|
2024-07-14 09:03:18 -04:00
|
|
|
diff = system_command "git", args: ["-C", HOMEBREW_REPOSITORY, "diff", "--exit-code", "README.md"]
|
2024-03-21 22:10:12 -07:00
|
|
|
if diff.status.success?
|
|
|
|
ofail "No changes to list of maintainers."
|
|
|
|
else
|
|
|
|
Manpages.regenerate_man_pages(quiet: true)
|
|
|
|
puts "List of maintainers updated in the README and the generated man pages."
|
|
|
|
end
|
|
|
|
end
|
2021-02-04 17:00:50 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|