Class: Homebrew::DevCmd::UpdateMaintainers Private

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

Overview

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.

DO NOT EDIT MANUALLY This is an autogenerated file for dynamic methods in Homebrew::DevCmd::UpdateMaintainers. Please instead update this file by running bin/tapioca dsl Homebrew::DevCmd::UpdateMaintainers.

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

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.



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

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
61
62
63
64
65
# 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")

  HOMEBREW_MAINTAINER_JSON.write(maintainers.keys.to_json)
  maintainer_json_relative_path = HOMEBREW_MAINTAINER_JSON.relative_path_from(HOMEBREW_REPOSITORY).to_s

  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.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", maintainer_json_relative_path
  ]
  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