Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Library/Homebrew/dev-cmd/contributions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,15 @@ def scan_contributions(organisation, repositories, repository_refs, users, from:

review_users = github_users.filter_map { |user, github_user| [user, github_user] if github_user }
review_users.reject! { |user, _| lead_activity_met?(results.fetch(user)) } if skip_reviews_if_lead_met
approved_to = Date.iso8601(to).prev_day.iso8601
review_users.each_with_index do |(user, github_user), index|
if progress
$stderr.puts "Querying approved-review search for #{user} (#{index + 1}/#{review_users.length})..."
end
approved_reviews = cached_github_request(Array, "approved", organisation, github_user, from, to, to:) do
GitHub.search_approved_pull_requests_in_user_or_organisation(organisation, github_user, from:, to:)
approved_reviews = cached_github_request(Array, "approved", organisation, github_user, from, approved_to,
to:) do
GitHub.search_approved_pull_requests_in_user_or_organisation(organisation, github_user,
from:, to: approved_to)
end
capped_reviews = approved_reviews.length >= MAX_PR_SEARCH
results.fetch(user).fetch(repositories.fetch(0))[:approved_pr_review_hit_cap] = 1 if capped_reviews
Expand All @@ -496,9 +499,10 @@ def scan_contributions(organisation, repositories, repository_refs, users, from:
qualifying_total >= MAINTAINER_ACTIVITY_THRESHOLD

$stderr.puts "Querying approved-review search for #{user} in #{repository}..." if progress
repository_reviews = cached_github_request(Array, "approved", repository, github_user, from, to, to:) do
repository_reviews = cached_github_request(Array, "approved", repository, github_user,
from, approved_to, to:) do
GitHub.search_issues("", is: "pr", review: "approved", repo: repository, reviewed_by: github_user,
from:, to:)
from:, to: approved_to)
end
repository_counts[:approved_pr_review] = repository_reviews.length
end
Expand Down
10 changes: 5 additions & 5 deletions Library/Homebrew/test/dev-cmd/contributions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@
.with("", is: "merged", user: "Homebrew", author: "alice", merged: "2026-01-01..2026-01-31")
.and_return([{ "number" => 123, "repository_url" => "#{GitHub::API_URL}/repos/#{repository}" }])
expect(GitHub).to receive(:search_approved_pull_requests_in_user_or_organisation)
.with("Homebrew", "alice", from: "2026-01-01", to: "2026-02-01")
.with("Homebrew", "alice", from: "2026-01-01", to: "2026-01-31")
.and_return([])

results = command.scan_contributions(
Expand Down Expand Up @@ -944,13 +944,13 @@
.with("", is: "merged", user: "Homebrew", author: "alice", merged: "2025-12-01..2026-02-28")
.and_return([])
allow(GitHub).to receive(:search_approved_pull_requests_in_user_or_organisation)
.with("Homebrew", "alice", from: "2025-12-01", to: "2026-03-01")
.with("Homebrew", "alice", from: "2025-12-01", to: "2026-02-28")
.and_return(Array.new(100) do
{ "repository_url" => "#{GitHub::API_URL}/repos/Homebrew/homebrew-cask" }
end)
expect(GitHub).to receive(:search_issues)
.with("", is: "pr", review: "approved", repo: "Homebrew/brew", reviewed_by: "alice",
from: "2025-12-01", to: "2026-03-01")
from: "2025-12-01", to: "2026-02-28")
.and_return(Array.new(25) { {} })

results = command.scan_contributions(
Expand All @@ -969,7 +969,7 @@
end).to eq("Homebrew/brew" => 25, "Homebrew/homebrew-core" => 0, "Homebrew/homebrew-cask" => 100)
end

it "uses the existing approved review search" do
it "excludes the end date from approved review searches" do
command = described_class.new(["--maintainer-report-csv=2026-1"])
repositories = Homebrew::DevCmd::Contributions::PRIMARY_REPOS.to_h do |repository|
[repository, [Pathname("/#{repository}"), "origin/HEAD"]]
Expand All @@ -985,7 +985,7 @@
.with("", is: "merged", user: "Homebrew", author: "alice", merged: "2025-12-01..2026-02-28")
.and_return([])
allow(GitHub).to receive(:search_approved_pull_requests_in_user_or_organisation)
.with("Homebrew", "alice", from: "2025-12-01", to: "2026-03-01")
.with("Homebrew", "alice", from: "2025-12-01", to: "2026-02-28")
.and_return([
{ "repository_url" => "#{GitHub::API_URL}/repos/Homebrew/brew" },
{ "repository_url" => "#{GitHub::API_URL}/repos/Homebrew/homebrew-core" },
Expand Down
Loading