Skip to content

contributions: match co-authored commits made under a real name/email - #23926

Merged
MikeMcQuaid merged 4 commits into
mainfrom
contributions
Sep 17, 2026
Merged

MikeMcQuaid merged 4 commits into
mainfrom
contributions

Conversation

@iMichka

@iMichka iMichka commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

--user accepts GitHub usernames, but commits and Co-authored-by: trailers are attributed by git name/email, not GitHub login. Fetch each user's public name/email from their GitHub profile and add it to identity_users so parse_git_log can match their commits even when only a username was supplied.

Cache the profile lookups the same way as other GitHub API calls used by this command.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Copilot AI balanced review requested due to automatic review settings September 10, 2026 19:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Ambiguous display names can misattribute commits, and profile requests lack isolated tests.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds GitHub profile identities to improve contribution attribution.

Changes:

  • Fetches and caches public GitHub names/emails.
  • Includes profile identities when parsing Git history.
  • Generalises GitHub response caching.
File summaries
File Description
Library/Homebrew/dev-cmd/contributions.rb Adds profile-based identity matching and caching.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 3
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@dduugg dduugg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a commit to resolve the typecheck errors (generics are tricky) and failing specs (by stubbing the network call instead), I hope you don't mind.

The Copilot finding around shared GitHub display names seems unlikely, but valid. The missing test coverage finding would be good to close out as well. Deferring to you on resolving them.

Thanks for this!

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, couple more wee things

iMichka and others added 4 commits September 17, 2026 10:23
`--user` accepts GitHub usernames, but commits and `Co-authored-by:`
trailers are attributed by git name/email, not GitHub login. Fetch
each user's public name/email from their GitHub profile and add it to
`identity_users` so `parse_git_log` can match their commits even when
only a username was supplied.

Cache the profile lookups the same way as other GitHub API calls used
by this command.
`github_search_with_rate_limit` is shared by callers returning an
`Array` and, since profile lookups were added, a `Hash`. The `T.any`
return type didn't hold: existing callers still return an `Array`,
so Sorbet (statically and at runtime) rejected the declared `Hash`
result. Use a Sorbet type parameter so each call site's own return
type is inferred and enforced honestly.

Stub the new `GitHub::API.open_rest` profile lookup in existing
`scan_contributions` specs, since it now runs unconditionally for
every user and was making live HTTP calls in CI.
- Skip GitHub profile identities shared by multiple requested users
  rather than crediting whichever user was requested first, and match
  exact emails and GitHub no-reply usernames before names.
- Stop matching other emails' local parts, which credited unrelated
  committers. `github_noreply_username` replaces the four copies of
  that logic and the GitHub username joins each user's profile
  identities so users given as emails still match no-reply commits.
- Replace `github_search_with_rate_limit` with `cached_github_request`,
  which takes the expected JSON class and the cache key parts, keeps
  the NUL key separator in one commented place and warns before
  deleting unreadable or wrongly typed cache files.
- Key profile and public-email lookups by `to` so stale names, emails
  and usernames are refreshed each reporting period.
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Sep 17, 2026
@MikeMcQuaid
MikeMcQuaid removed this pull request from the merge queue due to a manual request Sep 17, 2026
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Sep 17, 2026
Merged via the queue into main with commit e0042bf Sep 17, 2026
63 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the contributions branch September 17, 2026 09:47
@iMichka

iMichka commented Sep 21, 2026

Copy link
Copy Markdown
Member Author

Thanks @MikeMcQuaid for finishing this one, I was ill the last few days and did not have the energy to look at it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

⌂ 换网址