Repository navigation
contributions: match co-authored commits made under a real name/email - #23926
Conversation
There was a problem hiding this comment.
🟡 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.
3385e97 to
6651908
Compare
1b3c156 to
b083051
Compare
dduugg
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Thanks, couple more wee things
`--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.
a637b47 to
5553e7b
Compare
|
Thanks @MikeMcQuaid for finishing this one, I was ill the last few days and did not have the energy to look at it :) |
--useraccepts GitHub usernames, but commits andCo-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 toidentity_userssoparse_git_logcan 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.
brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?