Class: Homebrew::DevCmd::UpdateMaintainers

Inherits:
AbstractCommand show all
Includes:
SystemCommand::Mixin
Defined in:
dev-cmd/update-maintainers.rb

Instance Attribute Summary

Attributes inherited from AbstractCommand

#args

Instance Method Summary collapse

Methods included from SystemCommand::Mixin

#system_command, #system_command!

Methods inherited from AbstractCommand

command, command_name, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#runvoid

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