Merge pull request #10518 from nandahkrishna/update-maintainers-dev-cmd

`brew update-maintainers`: dev-cmd to update maintainers in README
This commit is contained in:
Nanda H Krishna 2021-02-09 00:01:18 +05:30 committed by GitHub
commit b1c5394628
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 170 additions and 5 deletions

View File

@ -36,8 +36,9 @@ Metrics/PerceivedComplexity:
Max: 90
Metrics/MethodLength:
Max: 260
# TODO: Reduce to 600 after refactoring utils/github
Metrics/ModuleLength:
Max: 600
Max: 620
Exclude:
- "test/**/*"

View File

@ -88,7 +88,7 @@ module Homebrew
readme.read[/(Homebrew's \[Technical Steering Committee.*\.)/, 1]
.gsub(/\[([^\]]+)\]\([^)]+\)/, '\1')
variables[:linux] =
readme.read[%r{(Homebrew/brew's Linux maintainers .*\.)}, 1]
readme.read[/(Homebrew's Linux maintainers .*\.)/, 1]
.gsub(/\[([^\]]+)\]\([^)]+\)/, '\1')
variables[:maintainers] =
readme.read[/(Homebrew's other current maintainers .*\.)/, 1]

View File

@ -0,0 +1,67 @@
# typed: false
# frozen_string_literal: true
require "cli/parser"
require "utils/github"
module Homebrew
extend T::Sig
module_function
sig { returns(CLI::Parser) }
def update_maintainers_args
Homebrew::CLI::Parser.new do
description <<~EOS
Update the list of maintainers in the `Homebrew/brew` README.
EOS
named_args :none
end
end
def update_maintainers
update_maintainers_args.parse
# We assume that only public members wish to be included in the README
public_members = GitHub.public_member_usernames("Homebrew")
members = {
plc: GitHub.members_by_team("Homebrew", "plc"),
tsc: GitHub.members_by_team("Homebrew", "tsc"),
linux: GitHub.members_by_team("Homebrew", "linux"),
}
members[:other] = GitHub.members_by_team("Homebrew", "maintainers")
.except(*members.values.map(&:keys).flatten.uniq)
sentences = {}
members.each do |group, hash|
hash.slice!(*public_members)
hash.each { |login, name| hash[login] = "[#{name}](https://github.com/#{login})" }
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 Linux maintainers are).*\./,
"\\1 #{sentences[:linux]}.")
content.gsub!(/(Homebrew's other current maintainers are).*\./,
"\\1 #{sentences[:other]}.")
File.open(readme, "w+") { |f| f.write(content) }
diff = system_command "git", args: [
"-C", HOMEBREW_REPOSITORY, "diff", "--exit-code", "README.md"
]
if diff.status.success?
puts "No changes to list of maintainers."
else
puts "List of maintainers updated in README."
end
end
end

View File

@ -0,0 +1,8 @@
# typed: false
# frozen_string_literal: true
require "cmd/shared_examples/args_parse"
describe "brew update-maintainers" do
it_behaves_like "parseable arguments"
end

View File

@ -50,6 +50,13 @@ describe GitHub do
end
end
describe "::public_member_usernames", :needs_network do
it "gets the usernames of all publicly visible members of the organisation" do
response = described_class.public_member_usernames("Homebrew")
expect(response).to be_a(Array)
end
end
describe "::sponsors_by_tier", :needs_network do
it "errors on an unauthenticated token" do
expect {

View File

@ -572,6 +572,47 @@ module GitHub
artifact.first["archive_download_url"]
end
def public_member_usernames(org, per_page: 100)
url = "#{API_URL}/orgs/#{org}/public_members?per_page=#{per_page}"
members = []
(1..API_MAX_PAGES).each do |page|
result = open_api("#{url}&page=#{page}").map { |member| member["login"] }
members.concat(result)
return members if result.length < per_page
end
end
def members_by_team(org, team)
query = <<~EOS
{ organization(login: "#{org}") {
teams(first: 100) {
nodes {
... on Team { name }
}
}
team(slug: "#{team}") {
members(first: 100) {
nodes {
... on User { login name }
}
}
}
}
}
EOS
result = open_graphql(query, scopes: ["read:org", "user"])
if result["organization"]["teams"]["nodes"].blank?
raise Error,
"Your token needs the 'read:org' scope to access this API"
end
raise Error, "The team #{org}/#{team} does not exist" if result["organization"]["team"].blank?
result["organization"]["team"]["members"]["nodes"].map { |member| [member["login"], member["name"]] }.to_h
end
def sponsors_by_tier(user)
query = <<~EOS
{ organization(login: "#{user}") {

View File

@ -56,7 +56,7 @@ Homebrew's [Project Leadership Committee](https://docs.brew.sh/Homebrew-Governan
Homebrew's [Technical Steering Committee](https://docs.brew.sh/Homebrew-Governance#7-technical-steering-committee) is [Michka Popoff](https://github.com/imichka), [FX Coudert](https://github.com/fxcoudert), [Markus Reiter](https://github.com/reitermarkus), [Misty De Meo](https://github.com/mistydemeo) and [Mike McQuaid](https://github.com/MikeMcQuaid).
Homebrew/brew's Linux maintainers are [Michka Popoff](https://github.com/imichka), [Shaun Jackman](https://github.com/sjackman), [Dawid Dziurla](https://github.com/dawidd6), [Issy Long](https://github.com/issyl0) and [Maxim Belkin](https://github.com/maxim-belkin).
Homebrew's Linux maintainers are [Michka Popoff](https://github.com/imichka), [Shaun Jackman](https://github.com/sjackman), [Dawid Dziurla](https://github.com/dawidd6), [Issy Long](https://github.com/issyl0) and [Maxim Belkin](https://github.com/maxim-belkin).
Homebrew's other current maintainers are [Claudia Pellegrino](https://github.com/claui), [Zach Auten](https://github.com/zachauten), [Rui Chen](https://github.com/chenrui333), [Vitor Galvao](https://github.com/vitorgalvao), [Caleb Xu](https://github.com/alebcay), [Gautham Goli](https://github.com/GauthamGoli), [Steven Peters](https://github.com/scpeters), [Bo Anderson](https://github.com/Bo98), [William Woodruff](https://github.com/woodruffw), [Igor Kapkov](https://github.com/igas), [Sam Ford](https://github.com/samford), [Alexander Bayandin](https://github.com/bayandin), [Izaak Beekman](https://github.com/zbeekman), [Eric Knibbe](https://github.com/EricFromCanada), [Viktor Szakats](https://github.com/vszakats), [Thierry Moisan](https://github.com/moisan), [Steven Peters](https://github.com/scpeters), [Tom Schoonjans](https://github.com/tschoonj), [Issy Long](https://github.com/issyl0), [CoreCode](https://github.com/core-code), [Randall](https://github.com/ran-dall), [Rylan Polster](https://github.com/Rylan12), [SeekingMeaning](https://github.com/SeekingMeaning), [William Ma](https://github.com/whoiswillma) and [Dustin Rodrigues](https://github.com/dtrodrigues).

View File

@ -2108,6 +2108,21 @@ _brew_update_license_data() {
esac
}
_brew_update_maintainers() {
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
-*)
__brewcomp "
--debug
--help
--quiet
--verbose
"
return
;;
esac
}
_brew_update_python_resources() {
local cur="${COMP_WORDS[COMP_CWORD]}"
case "$cur" in
@ -2382,6 +2397,7 @@ _brew() {
up) _brew_up ;;
update) _brew_update ;;
update-license-data) _brew_update_license_data ;;
update-maintainers) _brew_update_maintainers ;;
update-python-resources) _brew_update_python_resources ;;
update-report) _brew_update_report ;;
update-test) _brew_update_test ;;

View File

@ -1439,6 +1439,13 @@ __fish_brew_complete_arg 'update-license-data' -l quiet -d 'Make some output mor
__fish_brew_complete_arg 'update-license-data' -l verbose -d 'Make some output more verbose'
__fish_brew_complete_cmd 'update-maintainers' 'Update the list of maintainers in the `Homebrew/brew` README'
__fish_brew_complete_arg 'update-maintainers' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'update-maintainers' -l help -d 'Show this message'
__fish_brew_complete_arg 'update-maintainers' -l quiet -d 'Make some output more quiet'
__fish_brew_complete_arg 'update-maintainers' -l verbose -d 'Make some output more verbose'
__fish_brew_complete_cmd 'update-python-resources' 'Update versions for PyPI resource blocks in formula'
__fish_brew_complete_arg 'update-python-resources' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'update-python-resources' -l exclude-packages -d 'Exclude these packages when finding resources'

View File

@ -97,6 +97,7 @@ untap
up
update
update-license-data
update-maintainers
update-python-resources
update-reset
update-test

View File

@ -212,6 +212,7 @@ __brew_internal_commands() {
'untap:Remove a tapped formula repository'
'update:Fetch the newest version of Homebrew and all formulae from GitHub using `git`(1) and perform any necessary migrations'
'update-license-data:Update SPDX license data in the Homebrew repository'
'update-maintainers:Update the list of maintainers in the `Homebrew/brew` README'
'update-python-resources:Update versions for PyPI resource blocks in formula'
'update-report:The Ruby implementation of `brew update`'
'update-reset:Fetch and reset Homebrew and all tap repositories (or any specified repository) using `git`(1) to their latest `origin/HEAD`'
@ -1677,6 +1678,15 @@ _brew_update_license_data() {
'--verbose[Make some output more verbose]'
}
# brew update-maintainers
_brew_update_maintainers() {
_arguments \
'--debug[Display any debugging information]' \
'--help[Show this message]' \
'--quiet[Make some output more quiet]' \
'--verbose[Make some output more verbose]'
}
# brew update-python-resources
_brew_update_python_resources() {
_arguments \

View File

@ -1384,6 +1384,10 @@ Update SPDX license data in the Homebrew repository.
* `--fail-if-not-changed`:
Return a failing status code if current license data's version is the same as the upstream. This can be used to notify CI when the SPDX license data is out of date.
### `update-maintainers`
Update the list of maintainers in the `Homebrew/brew` README.
### `update-python-resources` [*`options`*] *`formula`* [...]
Update versions for PyPI resource blocks in *`formula`*.
@ -1961,7 +1965,7 @@ Homebrew's Project Leadership Committee is Misty De Meo, Shaun Jackman, Jonathan
Homebrew's Technical Steering Committee is Michka Popoff, FX Coudert, Markus Reiter, Misty De Meo and Mike McQuaid.
Homebrew/brew's Linux maintainers are Michka Popoff, Shaun Jackman, Dawid Dziurla, Issy Long and Maxim Belkin.
Homebrew's Linux maintainers are Michka Popoff, Shaun Jackman, Dawid Dziurla, Issy Long and Maxim Belkin.
Homebrew's other current maintainers are Claudia Pellegrino, Zach Auten, Rui Chen, Vitor Galvao, Caleb Xu, Gautham Goli, Steven Peters, Bo Anderson, William Woodruff, Igor Kapkov, Sam Ford, Alexander Bayandin, Izaak Beekman, Eric Knibbe, Viktor Szakats, Thierry Moisan, Steven Peters, Tom Schoonjans, Issy Long, CoreCode, Randall, Rylan Polster, SeekingMeaning, William Ma and Dustin Rodrigues.

View File

@ -1916,6 +1916,9 @@ Update SPDX license data in the Homebrew repository\.
\fB\-\-fail\-if\-not\-changed\fR
Return a failing status code if current license data\'s version is the same as the upstream\. This can be used to notify CI when the SPDX license data is out of date\.
.
.SS "\fBupdate\-maintainers\fR"
Update the list of maintainers in the \fBHomebrew/brew\fR README\.
.
.SS "\fBupdate\-python\-resources\fR [\fIoptions\fR] \fIformula\fR [\.\.\.]"
Update versions for PyPI resource blocks in \fIformula\fR\.
.
@ -2846,7 +2849,7 @@ Homebrew\'s Project Leadership Committee is Misty De Meo, Shaun Jackman, Jonatha
Homebrew\'s Technical Steering Committee is Michka Popoff, FX Coudert, Markus Reiter, Misty De Meo and Mike McQuaid\.
.
.P
Homebrew/brew\'s Linux maintainers are Michka Popoff, Shaun Jackman, Dawid Dziurla, Issy Long and Maxim Belkin\.
Homebrew\'s Linux maintainers are Michka Popoff, Shaun Jackman, Dawid Dziurla, Issy Long and Maxim Belkin\.
.
.P
Homebrew\'s other current maintainers are Claudia Pellegrino, Zach Auten, Rui Chen, Vitor Galvao, Caleb Xu, Gautham Goli, Steven Peters, Bo Anderson, William Woodruff, Igor Kapkov, Sam Ford, Alexander Bayandin, Izaak Beekman, Eric Knibbe, Viktor Szakats, Thierry Moisan, Steven Peters, Tom Schoonjans, Issy Long, CoreCode, Randall, Rylan Polster, SeekingMeaning, William Ma and Dustin Rodrigues\.