Merge pull request #20666 from Homebrew/contributions_team
dev-cmd/contributions: add `--team` flag.
This commit is contained in:
commit
29270a8858
@ -42,6 +42,9 @@ module Homebrew
|
||||
flag "--organisation=", "--organization=", "--org=",
|
||||
description: "Specify the organisation to populate sources repositories from. " \
|
||||
"Omitting this flag searches the Homebrew primary repositories."
|
||||
flag "--team=",
|
||||
description: "Specify the team to populate users from. " \
|
||||
"The first part of the team name will be used as the organisation."
|
||||
flag "--from=",
|
||||
description: "Date (ISO 8601 format) to start searching contributions. " \
|
||||
"Omitting this flag searches the past year."
|
||||
@ -50,6 +53,8 @@ module Homebrew
|
||||
switch "--csv",
|
||||
description: "Print a CSV of contributions across repositories over the time period."
|
||||
conflicts "--organisation", "--repositories"
|
||||
conflicts "--organisation", "--team"
|
||||
conflicts "--user", "--team"
|
||||
end
|
||||
|
||||
sig { override.void }
|
||||
@ -58,15 +63,34 @@ module Homebrew
|
||||
|
||||
Homebrew.install_bundler_gems!(groups: ["contributions"]) if args.csv?
|
||||
|
||||
require "utils/github"
|
||||
|
||||
results = {}
|
||||
grand_totals = {}
|
||||
|
||||
from = args.from.presence || Date.today.prev_year.iso8601
|
||||
to = args.to.presence || (Date.today + 1).iso8601
|
||||
|
||||
organisation = nil
|
||||
repositories = if (org = args.organisation.presence)
|
||||
|
||||
users = if (team = args.team.presence)
|
||||
team_sections = team.split("/")
|
||||
organisation = team_sections.first.presence
|
||||
team_name = team_sections.last.presence
|
||||
if team_sections.length != 2 || organisation.nil? || team_name.nil?
|
||||
odie "Team must be in the format `organisation/team`!"
|
||||
end
|
||||
|
||||
puts "Getting members for #{organisation}/#{team_name}..." if args.verbose?
|
||||
GitHub.members_by_team(organisation, team_name).keys
|
||||
elsif (users = args.user.presence)
|
||||
users
|
||||
else
|
||||
puts "Getting members for Homebrew/maintainers..." if args.verbose?
|
||||
GitHub.members_by_team("Homebrew", "maintainers").keys
|
||||
end
|
||||
|
||||
repositories = if (org = organisation.presence) || (org = args.organisation.presence)
|
||||
organisation = org
|
||||
puts "Getting repositories for #{organisation}..." if args.verbose?
|
||||
GitHub.organisation_repositories(organisation, from, to, args.verbose?)
|
||||
elsif (repos = args.repositories.presence) && repos.length == 1 && (first_repository = repos.first)
|
||||
case first_repository
|
||||
@ -87,8 +111,6 @@ module Homebrew
|
||||
end
|
||||
organisation ||= T.must(repositories.fetch(0).split("/").first)
|
||||
|
||||
require "utils/github"
|
||||
users = args.user.presence || GitHub.members_by_team("Homebrew", "maintainers").keys
|
||||
users.each do |username|
|
||||
# TODO: Using the GitHub username to scan the `git log` undercounts some
|
||||
# contributions as people might not always have configured their Git
|
||||
|
@ -29,6 +29,9 @@ class Homebrew::DevCmd::Contributions::Args < Homebrew::CLI::Args
|
||||
sig { returns(T.nilable(T::Array[String])) }
|
||||
def repositories; end
|
||||
|
||||
sig { returns(T.nilable(String)) }
|
||||
def team; end
|
||||
|
||||
sig { returns(T.nilable(String)) }
|
||||
def to; end
|
||||
|
||||
|
@ -821,6 +821,7 @@ _brew_contributions() {
|
||||
--organisation
|
||||
--quiet
|
||||
--repositories
|
||||
--team
|
||||
--to
|
||||
--user
|
||||
--verbose
|
||||
|
@ -605,6 +605,7 @@ __fish_brew_complete_arg 'contributions' -l help -d 'Show this message'
|
||||
__fish_brew_complete_arg 'contributions' -l organisation -d 'Specify the organisation to populate sources repositories from. Omitting this flag searches the Homebrew primary repositories'
|
||||
__fish_brew_complete_arg 'contributions' -l quiet -d 'Make some output more quiet'
|
||||
__fish_brew_complete_arg 'contributions' -l repositories -d 'Specify a comma-separated list of repositories to search. All repositories must be under the same user or organisation. Omitting this flag, or specifying `--repositories=primary`, searches only the main repositories: `Homebrew/brew`, `Homebrew/homebrew-core`, `Homebrew/homebrew-cask`. Specifying `--repositories=all` searches all non-deprecated Homebrew repositories. '
|
||||
__fish_brew_complete_arg 'contributions' -l team -d 'Specify the team to populate users from. The first part of the team name will be used as the organisation'
|
||||
__fish_brew_complete_arg 'contributions' -l to -d 'Date (ISO 8601 format) to stop searching contributions'
|
||||
__fish_brew_complete_arg 'contributions' -l user -d 'Specify a comma-separated list of GitHub usernames or email addresses to find contributions from. Omitting this flag searches Homebrew maintainers'
|
||||
__fish_brew_complete_arg 'contributions' -l verbose -d 'Make some output more verbose'
|
||||
|
@ -769,11 +769,12 @@ _brew_contributions() {
|
||||
'--debug[Display any debugging information]' \
|
||||
'--from[Date (ISO 8601 format) to start searching contributions. Omitting this flag searches the past year]' \
|
||||
'--help[Show this message]' \
|
||||
'(--repositories)--organisation[Specify the organisation to populate sources repositories from. Omitting this flag searches the Homebrew primary repositories]' \
|
||||
'(--repositories --team)--organisation[Specify the organisation to populate sources repositories from. Omitting this flag searches the Homebrew primary repositories]' \
|
||||
'--quiet[Make some output more quiet]' \
|
||||
'(--organisation)--repositories[Specify a comma-separated list of repositories to search. All repositories must be under the same user or organisation. Omitting this flag, or specifying `--repositories=primary`, searches only the main repositories: `Homebrew/brew`, `Homebrew/homebrew-core`, `Homebrew/homebrew-cask`. Specifying `--repositories=all` searches all non-deprecated Homebrew repositories. ]' \
|
||||
'(--organisation --user)--team[Specify the team to populate users from. The first part of the team name will be used as the organisation]' \
|
||||
'--to[Date (ISO 8601 format) to stop searching contributions]' \
|
||||
'--user[Specify a comma-separated list of GitHub usernames or email addresses to find contributions from. Omitting this flag searches Homebrew maintainers]' \
|
||||
'(--team)--user[Specify a comma-separated list of GitHub usernames or email addresses to find contributions from. Omitting this flag searches Homebrew maintainers]' \
|
||||
'--verbose[Make some output more verbose]'
|
||||
}
|
||||
|
||||
|
@ -2426,6 +2426,11 @@ Summarise contributions to Homebrew repositories.
|
||||
: Specify the organisation to populate sources repositories from. Omitting this
|
||||
flag searches the Homebrew primary repositories.
|
||||
|
||||
`--team`
|
||||
|
||||
: Specify the team to populate users from. The first part of the team name will
|
||||
be used as the organisation.
|
||||
|
||||
`--from`
|
||||
|
||||
: Date (ISO 8601 format) to start searching contributions. Omitting this flag
|
||||
|
@ -1520,6 +1520,9 @@ Specify a comma\-separated list of repositories to search\. All repositories mus
|
||||
\fB\-\-organisation\fP
|
||||
Specify the organisation to populate sources repositories from\. Omitting this flag searches the Homebrew primary repositories\.
|
||||
.TP
|
||||
\fB\-\-team\fP
|
||||
Specify the team to populate users from\. The first part of the team name will be used as the organisation\.
|
||||
.TP
|
||||
\fB\-\-from\fP
|
||||
Date (ISO 8601 format) to start searching contributions\. Omitting this flag searches the past year\.
|
||||
.TP
|
||||
|
Loading…
x
Reference in New Issue
Block a user