New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dev-cmd/contributions: Retrieve a user's repo contributions over time #13603
Conversation
Review period will end on 2022-07-26 at 00:00:00 UTC. |
9d0d60d
to
ec0f9a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool idea!
Is it possible to use the GitHub API so this doesn't require having things tapped locally?
Technically probably yes, but I dread to think how many API rate limits we'll hit for the commit searches across all the things. I know the JSON stuff will mean that at some point we won't have all the repos tapped. I'll look into it and try some things out. But I'm thinking "future enhancement"? |
Yeah, I was thinking that if there was an equivalent API endpoint for
I mean yes, but developers will (mostly) need to have the repos tapped anyway for editing files and the like, so I'm not worried about this. Since it's a dev cmd, it's not a problem to just require the repo to be tapped. |
f083b94
to
c22efba
Compare
There's the commits API, but it's maximum 100 commits per page. 😩
😅 |
d65daca
to
7ab7b65
Compare
@issyl0 there's an |
@issyl0 I think doing this by username would be better if possible; it's not always clear the correct email for a given user.
Ideally, we'd also be able to query e.g. ✅ or 🟥 reviews (i.e. those that require write access) to check those maintainer actions, too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great so far, nice work @issyl0!
Not sure if you want to handle this...
|
Review period ended. |
Marked this as draft since there's still a lot to do - thanks for all your comments! I'll finish this off by ~Thursday. |
974f8e9
to
dcbf414
Compare
@carlocab This doesn't happen anymore, that I can reproduce anyway. 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great so far! Feature request, not needing all to be handled in this PR:
- count both commit authors and commit committers
- count "PRs reviewed ✅ or 🟥 by" (which implies write access)
flag "--to=", | ||
description: "Date (ISO-8601 format) to stop searching contributions." | ||
|
||
comma_array "--repos=", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comma_array "--repos=", | |
comma_array "--repositories=", "--repos", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comma_array
doesn't take multiple name
s. Yet. I suppose I could fix that.
bdd2d97
to
fd57f9e
Compare
TODO (not all in this PR, I'm hoping to ship this soon, once this is in I'll write up an issue for the things that are left 😅):
|
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
- I got these with hash syntax because I couldn't figure out Sorbet, but there's `args.rbi` to add the CLI args methods to. Nice! - In doing this I realised that `--repositories` is required again, we no longer infer `--repositories=all` from no `--repositories` passed as we did in a previous version of this.
- This is apparently "more in-keeping with how we do required arguments (never requiring flags)" across Homebrew. - New usage: `brew contributions me@issyl0.co.uk all`, `brew contributions me@issyl0.co.uk brew,core`
- This is easier than mapping GitHub usernames to email addresses, when folks don't have email addresses always public on their GitHub profiles. Also, the users of this command (PLC members, other interested parties) don't have to remember folks' email addresses. - It also gives better data for people who've changed their name over the years, and who commit with multiple email addresses (personal and work). ``` ❯ brew contributions "Issy Long" all Person Issy Long directly authored 687 commits and co-authored 33 commits across all Homebrew repos in all time. ❯ brew contributions "Rylan Polster" all Person Rylan Polster directly authored 1747 commits and co-authored 133 commits across all Homebrew repos in all time. ❯ brew contributions me@issyl0.co.uk all Person me@issyl0.co.uk directly authored 711 commits and co-authored 25 commits across all Homebrew repos in all time. ❯ brew contributions "Mike McQuaid" all Person Mike McQuaid directly authored 26879 commits and co-authored 204 commits across all Homebrew repos in all time. ```
Co-authored-by: Rylan Polster <rslpolster@gmail.com>
Co-authored-by: Rylan Polster <rslpolster@gmail.com>
Co-authored-by: Rylan Polster <rslpolster@gmail.com>
- Also stop skipping a "versions" repo. Since 0232610 the `Homebrew/homebrew-cask-versions` tap won't get mistaken for `Homebrew/homebrew-versions` tap.
40b53e1
to
3133166
Compare
- This doesn't require "all" to be specified as part of the command, it's the default, so usage is now just: ``` $ brew contributions "Issy Long" $ brew contributions "Issy Long" --repositories=brew,core $ brew contributions me@issyl0.co.uk --repositories=cask,bundle ``` - As we discussed in the PR review before, `comma_array` doesn't allow two names, so we can't (yet) do `comma_array "--repositories", "--repos"` like we can with `flag`. That's an enhancement for the future if we want to make the flags here less verbose. But now that "all" is the default, maybe less necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor things
SUPPORTED_REPOS = [ | ||
%w[brew core cask], | ||
OFFICIAL_CMD_TAPS.keys.map { |t| t.delete_prefix("homebrew/") }, | ||
OFFICIAL_CASK_TAPS.reject { |t| t == "cask" }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to block this PR, but isn't OFFICIAL_CASK_TAPS
still missing cask-drivers
and cask-fonts
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I don't know why those don't exist. Casks aren't my area of expertise. I'll do a separate PR to add them and see what folks say.
|
||
comma_array "--repositories", | ||
description: "Specify a comma-separated (no spaces) list of repositories to search. " \ | ||
"Supported repositories: #{SUPPORTED_REPOS.join(", ")}. " \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, not really blocking but we could use #to_sentence
here. Also, it might be nice to get backticks around the options so they stand out (unless you think that looks too chaotic or isn't worth the complexity)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Rylan Polster <rslpolster@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Nice work!
CodeCov is the only failing check now, and I've addressed all the immediate comments, so I'm going to merge this and write up an issue for the remaining things. Thanks for your reviews! |
- This is needed for Homebrew#13603 because `Homebrew/homebrew-versions` is deprecated (legitimately), but `OFFICIAL_CASK_TAPS` spits out `versions` as a repo, which could then be interpreted as `Homebrew/versions` rather than `Homebrew/cask-versions` which it actually is.
Thanks @issyl0! |
- This [came up](Homebrew#13603 (comment)) when developing `brew contributions`, the `--repositories` flag (comma array) is long to type. It turned out that unlike normal flags, `comma_array`s didn't allow multiple arg names. - Now in `brew contributions` (and potentially elsewhere, though I've not had a look) we can make the args easier to type by letting `--repositories` and `--repos` equate to the same thing.
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Co-Authored-By
, which happens a lot now there's an autosquash action on PRs inHomebrew/homebrew-core
, say if someone fixed a formula's build or tests or whatever and then the PR got auto-merged.brew contributions
that usesgit log
to be able to go back through all time or a specific time period (--from
,--to
). It's up to individual PLC discretion for "activity", but it does at least go some way to automating the data retrieval.--email
because my username is in all of the email addresses that I use for committing to Homebrew):Future enhancement ideas:
--username=
flag to specify a GitHub username (instead of/as well as an email). As we know, open source isn't all about code, but reviews count as well as they're extremely valuable with the number of PRs we get. We could get data on how many reviews a user has submitted on PRs. And maybe we could use--username
to retrieve the user's email addresses from GitHub too, so that the user of this script doesn't need to know them.