From 28a2a6ea436ee38e234208a25393d26442f5bfac Mon Sep 17 00:00:00 2001 From: Issy Long Date: Wed, 22 Feb 2023 23:01:38 +0000 Subject: [PATCH] utils/github: Add date filtering to the commit author API query - I missed this off the original implementation - oops. This gives parity with the `git log` implementation. --- Library/Homebrew/dev-cmd/contributions.rb | 2 +- Library/Homebrew/utils/github.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/dev-cmd/contributions.rb b/Library/Homebrew/dev-cmd/contributions.rb index e3ddbcb45c..90741e4e61 100755 --- a/Library/Homebrew/dev-cmd/contributions.rb +++ b/Library/Homebrew/dev-cmd/contributions.rb @@ -143,7 +143,7 @@ module Homebrew puts "Determining contributions for #{person} on #{repo_full_name}..." if args.verbose? data[repo] = { - commits: GitHub.repo_commit_count_for_user(repo_full_name, person), + commits: GitHub.repo_commit_count_for_user(repo_full_name, person, args), coauthorships: git_log_trailers_cmd(T.must(repo_path), person, "Co-authored-by", args), signoffs: git_log_trailers_cmd(T.must(repo_path), person, "Signed-off-by", args), } diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index e4fc791c4c..1ca085109b 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -700,11 +700,15 @@ module GitHub output[/^Status: (200)/, 1] != "200" end - def repo_commit_count_for_user(nwo, user) + def repo_commit_count_for_user(nwo, user, args) return if Homebrew::EnvConfig.no_github_api? + params = ["author=#{user}"] + params << "since=#{DateTime.parse(args.from).iso8601}" if args.from + params << "until=#{DateTime.parse(args.to).iso8601}" if args.to + commits = 0 - API.paginate_rest("#{API_URL}/repos/#{nwo}/commits", additional_query_params: "author=#{user}") do |result| + API.paginate_rest("#{API_URL}/repos/#{nwo}/commits", additional_query_params: params.join("&")) do |result| commits += result.length end commits