Class: Homebrew::DevCmd::UpdateMaintainers Private

Inherits:
AbstractCommand show all
Includes:
SystemCommand::Mixin
Defined in:
dev-cmd/update-maintainers.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/update_maintainers.rbi

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods included from SystemCommand::Mixin

#system_command, #system_command!

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser, ruby_cmd?

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::DevCmd::UpdateMaintainers::Args

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



10
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/update_maintainers.rbi', line 10

def args; end

#runvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'dev-cmd/update-maintainers.rb', line 23

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")

  members = {
    plc:         GitHub.members_by_team("Homebrew", "plc"),
    tsc:         GitHub.members_by_team("Homebrew", "tsc"),
    maintainers:,
  }

  sentences = {}
  members.each do |group, hash|
    hash.replace(hash.slice(*public_members))
    hash.each { |, name| hash[] = "[#{name}](https://github.com/#{})" }
    sentences[group] = hash.values.sort_by { |s| s.unicode_normalize(:nfd).gsub(/\P{L}+/, "") }.to_sentence
  end

  readme = HOMEBREW_REPOSITORY/"README.md"

  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]}.")

  File.write(readme, content)

  diff = system_command "git", args: ["-C", HOMEBREW_REPOSITORY, "diff", "--exit-code", "README.md"]
  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