Merge pull request #14775 from issyl0/github-api-commits-support-since-until
utils/github: Add date filtering to the commit author API query
This commit is contained in:
commit
43209a1af1
@ -70,7 +70,6 @@ module Homebrew
|
|||||||
|
|
||||||
maintainers = GitHub.members_by_team("Homebrew", "maintainers")
|
maintainers = GitHub.members_by_team("Homebrew", "maintainers")
|
||||||
maintainers.each do |username, _|
|
maintainers.each do |username, _|
|
||||||
puts "Determining contributions for #{username}..." if args.verbose?
|
|
||||||
# TODO: Using the GitHub username to scan the `git log` undercounts some
|
# TODO: Using the GitHub username to scan the `git log` undercounts some
|
||||||
# contributions as people might not always have configured their Git
|
# contributions as people might not always have configured their Git
|
||||||
# committer details to match the ones on GitHub.
|
# committer details to match the ones on GitHub.
|
||||||
@ -143,7 +142,7 @@ module Homebrew
|
|||||||
puts "Determining contributions for #{person} on #{repo_full_name}..." if args.verbose?
|
puts "Determining contributions for #{person} on #{repo_full_name}..." if args.verbose?
|
||||||
|
|
||||||
data[repo] = {
|
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),
|
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),
|
signoffs: git_log_trailers_cmd(T.must(repo_path), person, "Signed-off-by", args),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -700,11 +700,15 @@ module GitHub
|
|||||||
output[/^Status: (200)/, 1] != "200"
|
output[/^Status: (200)/, 1] != "200"
|
||||||
end
|
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?
|
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
|
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
|
commits += result.length
|
||||||
end
|
end
|
||||||
commits
|
commits
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user