Class: Homebrew::DevCmd::Contributions Private
- Inherits:
-
AbstractCommand
- Object
- AbstractCommand
- Homebrew::DevCmd::Contributions
- Defined in:
- dev-cmd/contributions.rb,
sorbet/rbi/dsl/homebrew/dev_cmd/contributions.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
Constant Summary collapse
- PRIMARY_REPOS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
T.let(%w[brew core cask].freeze, T::Array[String])
- SUPPORTED_REPOS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
T.let([ PRIMARY_REPOS, OFFICIAL_CMD_TAPS.keys.map { |t| t.delete_prefix("homebrew/") }, OFFICIAL_CASK_TAPS.reject { |t| t == "cask" }, ].flatten.freeze, T::Array[String])
- MAX_REPO_COMMITS =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
1000
Instance Method Summary collapse
- #args ⇒ Homebrew::DevCmd::Contributions::Args private
- #run ⇒ void private
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
#args ⇒ Homebrew::DevCmd::Contributions::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/contributions.rbi', line 10 def args; end |
#run ⇒ void
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.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'dev-cmd/contributions.rb', line 45 def run results = {} grand_totals = {} repos = T.must( if args.repositories.blank? || args.repositories&.include?("primary") PRIMARY_REPOS elsif args.repositories&.include?("all") SUPPORTED_REPOS else args.repositories end, ) repos.each do |repo| if SUPPORTED_REPOS.exclude?(repo) odie "Unsupported repository: #{repo}. Try one of #{SUPPORTED_REPOS.join(", ")}." end end from = args.from.presence || Date.today.prev_year.iso8601 contribution_types = [:author, :committer, :coauthor, :review] 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 # committer details to match the ones on GitHub. # TODO: Switch to using the GitHub APIs instead of `git log` if # they ever support trailers. results[username] = scan_repositories(repos, username, from:) grand_totals[username] = total(results[username]) contributions = contribution_types.filter_map do |type| type_count = grand_totals[username][type] next if type_count.to_i.zero? "#{Utils.pluralize("time", type_count, include_count: true)} (#{type})" end contributions << "#{Utils.pluralize("time", grand_totals[username].values.sum, include_count: true)} (total)" puts [ "#{username} contributed", *contributions.to_sentence, "#{time_period(from:, to: args.to)}.", ].join(" ") end return unless args.csv? puts puts generate_csv(grand_totals) end |