Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses missing contributors on large repos/orgs by switching get_contributors() to a commits-first strategy for date-bounded runs, reducing API calls and rate-limit risk while making counts reflect the selected period.
Changes:
- Refactors
get_contributors()to enumerate commits in thestart_date/end_daterange and aggregate unique authors/counts. - Updates and adds unit tests to cover commit aggregation and skipping commits with
Noneauthors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
contributors.py |
Implements commits-first contributor discovery and per-period contribution counting when a date range is provided. |
test_contributors.py |
Updates existing tests for the new behavior and adds new cases for None authors and aggregation across multiple commits. |
Comments suppressed due to low confidence (1)
test_contributors.py:140
test_get_contributors_skip_users_with_no_commits(and its docstring) no longer matches what the test actually verifies after the commits-first refactor; it now asserts the happy path with a single commit. Renaming the test and updating the docstring to reflect the current behavior will keep the suite understandable and avoid future confusion.
@patch("contributors.contributor_stats.ContributorStats")
def test_get_contributors_skip_users_with_no_commits(self, mock_contributor_stats):
"""
Test the get_contributors function skips users with no commits in the date range.
"""
mock_repo = MagicMock()
mock_commit = MagicMock()
mock_commit.author.login = "user"
mock_commit.author.avatar_url = (
"https://avatars.githubusercontent.com/u/12345678?v=4"
)
mock_repo.full_name = "owner/repo"
mock_repo.commits.return_value = iter([mock_commit])
ghe = ""
…ntributors When date filtering is active, fetch commits in the date range directly and extract unique authors, instead of iterating all-time contributors and making a separate API call per contributor to check for commits. The previous approach made O(N) API calls where N is the number of all-time contributors, which exhausted rate limits on large repos/orgs. When rate limiting occurred mid-iteration, the broad exception handler silently dropped all contributors for the affected repository. The new approach makes O(M/30) API calls where M is the number of commits in the date range, which is orders of magnitude fewer for monthly reports. Additionally, contribution_count now reflects the actual count for the specified period rather than the misleading all-time count. Fixes #392 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
796dc07 to
545219a
Compare
Address PR review feedback: - Add return value assertions to test_get_contributors and test_get_contributors_skip_bot for stricter contract verification - Rename test_get_contributors_skip_users_with_no_commits to test_get_contributors_with_single_commit to match actual behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jmeridth
approved these changes
Feb 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #392 — contributors silently dropped from output due to rate limiting on large repos/orgs.
Problem
When
start_dateandend_dateare set,get_contributors()fetches all-time contributors viarepo.contributors(), then makes a separate API call per contributor to check for commits in the date range. For large repos this causes rate limiting, and the broadexcept Exceptionhandler silently drops the entire repo's contributors.Solution
Use a commits-first approach: fetch commits in the date range directly (
repo.commits(since=, until=)) and extract unique authors. This reduces API calls from O(N) (all-time contributors) to O(M/30) (commits in period, paginated).Bonus:
contribution_countnow reflects the actual count for the specified period, not the all-time count.Testing
Noneauthor handling and commit aggregation)