80 Commits

Author SHA1 Message Date
Douglas Eichelberger
c50fb2dbd2 Remove redundant cli/parser requires 2024-03-29 18:53:07 -07:00
Douglas Eichelberger
9297a850aa Port Homebrew::DevCmd::Create 2024-03-21 19:04:30 -07:00
Douglas Eichelberger
6b19bc5535 Style cleanup 2024-03-20 10:36:19 -07:00
Douglas Eichelberger
0373e0dc29 Port Homebrew::DevCmd::Contributions 2024-03-20 10:36:19 -07:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Douglas Eichelberger
fe439e8320 Apply 'chmod -x' to executables without shebangs 2024-03-06 22:22:49 -08:00
Issy Long
f4218a6316
Fix RuboCop Performance/MapCompact offenses
- Rename an iterator variable since it would make the line too long.
2024-02-25 22:59:59 +00:00
Bo Anderson
5692c8ecbf
Fix style violations under newer RuboCop 2023-12-14 05:47:12 +00:00
Eric Knibbe
931f762598
docs+rubydoc: various grammar/wording fixes 2023-09-11 02:26:37 -04:00
Mike McQuaid
d357607b2c
dev-cmd/contributions: usability/performance improvements.
- more sensible/performant defaults: default to primary repositories
  only for the last year rather than all repositories forever
- allow specifying more than one user at a time
- output the breakdown of contributions without needing `--csv`
- add a space before the `--csv` output
- consolidate some code
- avoid counting authored commits twice, to improve performance
- retry failed GitHub API calls (this happens often when querying all
  maintainers)
- stop counting after we find 1000 commits for a given user to avoid
  excessive API queries/pagination
2023-08-30 15:08:50 +01:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Dustin Rodrigues
b776fb32de
change includecount to include_count for readability 2023-03-20 07:23:17 -04:00
Dustin Rodrigues
e5fba88035
use includecount argument in pluralize 2023-03-19 23:35:47 -04:00
Dustin Rodrigues
afae58b430
dev-cmd/contributions: fix typecheck errors 2023-03-19 17:34:35 -04:00
Dustin Rodrigues
834740f04c
dev-cmd/contributions: refactor to shorten line length 2023-03-19 17:12:11 -04:00
Dustin Rodrigues
a562d6deee
dev-cmd/contributions: appropriately pluralize contribution statement 2023-03-19 16:55:33 -04:00
Issy Long
a9e31274fc
dev-cmd/contributions: Output why we default to 0 reviews on a validation error 2023-03-15 21:31:41 +00:00
Issy Long
b6198cdd07
dev-cmd/contributions: Avoid the /users/#{user}/events API call
- This is wasteful when we can just catch the `ValidationFailedError`
  from the GitHub API from the search query.
2023-03-15 13:00:49 +00:00
Issy Long
0a804e1b38
dev-cmd/contributions: Use the correct variable name 🙄 2023-03-15 12:50:14 +00:00
Issy Long
03bd62ca0d
dev-cmd/contributions: Don't fall over if a user's profile is private
- It's possible to hide your contribution graph and not be searchable on
  GitHub. Let's make sure `brew contributions` doesn't fall over if the
  user's profile is private (determined by the `/events` user endpoint
  returning []).
2023-03-15 12:48:59 +00:00
Issy Long
edeefebf61
utils/github: Fix double counting of author/committer numbers
- The usage of this in `brew contributions` wasn't correct for a user
  with 5 authored commits to homebrew/cask that had been committed by
  other people, the numbers would turn out as 5 authored, 5 committed.
- I decided to do this properly by getting the SHAs for author and
  committer and determine the differences between the two arrays.
  This also accounts for when authored commits are 0, or committed
  commits, or both.
- Add tests, because I don't want to fix this a third time!
2023-03-05 14:41:04 +00:00
Issy Long
693d609730
dev-cmd/contributions: Fix authored vs. committed commit uniqueness
- For a situation where `authored = 3`, `committed = 4`, the previous
  calculation was `3 - 4` which meant that `committed = -1` in the end.
- This was incorrect, since a user can't have negative contributions!
- Instead, only do the subtraction to get the deduplicated `committed`
  count if the number of authored commits is higher than the number of
  committed commits. This approach should achieve the desired "don't
  double count things that the user authored and committed, but do count
  things that another person authored that the user committed".
2023-03-03 13:15:13 +00:00
Issy Long
fcb01e49a2
dev-cmd/contributions: Deduplicate same author/committer commits
- Double counting is artificially inflating folks' contributions (sadly ;-)).
- Since I'm not going to enumerate every possible author to filter by *both*
  fields via the API, let's do some arithmetic to figure out the unique
  committer numbers for a user.
2023-03-02 20:19:19 +00:00
Issy Long
4be55ddcc4
dev-cmd/contributions: Tidy up comments for data structures
- People can `pp results` or `pp totals`, updating these is getting tedious.
2023-03-01 23:45:08 +00:00
Issy Long
9250a6705e
dev-cmd/contributions: Count the number of commits a user committed
- The GitHub list commits API now supports this filtering
  (https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-commits--parameters),
  because I wrote it. :-)
- Authoring a commit and committing a commit are two separate concepts: author
  is the person who wrote the code and, in old parlance, the committer is the
  person who applied the patch (remember when we sent patches to mailing lists?).
- In practice for us in Homebrew, this occurs when we make a change in GitHub's
  web editor, or, more obviously, when BrewTestBot pushes `homebrew-core`
  commits from users (then, `BrewTestBot` is the `committer`).
2023-03-01 23:38:49 +00:00
Issy Long
b8b7e6350d
dev-cmd/contributions: Only count approving reviews
- The `reviewed-by` filter retrieved all reviews for a user, including
  those they'd added to their own PRs. Since it's impossible to click
  the "approve" button on one's own PR, filter this to `review:approved`
  to get "further project goals" kinds of reviews.
- Suggested in https://github.com/Homebrew/brew/pull/14813#discussion_r1118696385.
2023-02-28 12:58:21 +00:00
Issy Long
6b76e5e66f
dev-cmd/contributions: Stop counting signoffs now we have "real" reviews
- Signoffs were just a stopgap until we implemented getting "real"
  reviews for a user via the GitHub API. They were a suboptimal way of getting
  reviews because they only really exist in Homebrew/homebrew-core where
  BrewTestBot adds signoffs for each maintainer who reviewed the PR.
2023-02-28 11:12:51 +00:00
Issy Long
a2d31faa72
dev-cmd/contributions: Support date ranges in PR reviews query
- Now `brew contributions --from=2023-02-23 --to=2023-02-26` works to limit the
  results for reviews. I forgot this in the original implementation, again,
  ugh.
2023-02-26 23:34:53 +00:00
Issy Long
a13556a1a6
Merge pull request #14813 from issyl0/contributions-approvals 2023-02-26 15:23:11 +00:00
Issy Long
8c75eab88a
dev-cmd/contributions: Count PR reviews since they're super important
- The search APIs don't have that high a rate limit but we shouldn't need to
  worry about that too much because, to get counts, the JSON response comes
  with a `total_count` number.
2023-02-25 19:10:17 +00:00
Issy Long
7b8f1c8714
dev-cmd/contributions: Order the CSV by highest contributions total 2023-02-25 18:04:01 +00:00
Issy Long
e68379f5df
dev-cmd/contributions: Fill in the "total" CSV row
- Using the new "total across commits/coauthors/signoffs" data per-user,
  this also generates a more complete maintainers CSV.
2023-02-25 01:05:41 +00:00
Issy Long
8d4bdbafc4
dev-cmd/contributions: CSV output of totals per maintainer
- Turns out in my head a few days ago I was overcomplicating this. I had a
  brainwave while in the shower.
- Some refactoring so that we call `totals` to sum up the hash of hashes less,
  since the grand total numbers are now used in multiple places.
2023-02-23 23:35:45 +00:00
Issy Long
c7b06df72e
dev-cmd/contributions: One --verbose sentence per user is enough 2023-02-22 23:05:02 +00:00
Issy Long
28a2a6ea43
utils/github: Add date filtering to the commit author API query
- I missed this off the original implementation - oops. This gives parity with
  the `git log` implementation.
2023-02-22 23:01:38 +00:00
Issy Long
1b3fa0bef7
Merge pull request #14768 from issyl0/contributions-fix-trailers-args
dev-cmd/contributions: Correctly order the trailers method args
2023-02-22 17:41:23 +00:00
Issy Long
0d345c4257
dev-cmd/contributions: Correctly order the trailers method args
- Was this a bad merge conflict resolution, or me not paying enough
  attention another time?
2023-02-22 17:24:13 +00:00
Issy Long
3d3369c542
dev-cmd/contributions.rb: odie
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2023-02-22 17:02:22 +00:00
Issy Long
d40bd0ae3e
dev-cmd/contributions: Fix single-user handling; be more verbose
- `brew contributions --user=issyl0` was taking forever because it went
  through all maintainers first, because the conditionals were in the
  wrong order.
- This was too quiet, far too quiet, for something that takes so long.
- Now verbose mode tells you what repos it's scanning for a user.
2023-02-22 16:48:31 +00:00
Issy Long
214110f665
dev-cmd/contributions: Stats for all maintainers
- With `brew contributions`, this will output a list of stats
  (across the specified time period, or all time) for people in the
  "maintainers" team on GitHub.
- Add a `--user` flag for getting stats for a specific user (either
  username, name or email address).
- This assumes that their Git committer details are the same as their name is
  set to on GitHub.
- Show an error message if trying to generate a CSV for the full maintainer
  list, since I haven't worked out how to best show all of that info yet (or
  even how best to show only the totals across everything for every user) in
  that format.
2023-02-22 16:05:58 +00:00
Issy Long
93ce211ebd
Merge pull request #14737 from issyl0/api-commits-for-person
dev-cmd/contributions: Use GitHub APIs for commit author info
2023-02-22 14:12:16 +00:00
Issy Long
0a6c59c0b3
dev-cmd/contributions: Less disgusting way to determine brew's NWO 2023-02-21 00:51:32 +00:00
Issy Long
d3827b12f2
dev-cmd/contributions: Use GitHub APIs for commit author info
- Using `git log` was brittle with name changes and email address changes for
  contributors over the years unless we made a Git `mailmap` file which brings
  with it its own updatedness overhead.
- Let's use the GitHub commits API (importantly _not_ the search API) so that
  we can give it a username and it will return contributions associated with
  every email address on that user's account:
  https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-commits--parameters.
- This is quite significantly slower, but it's worth it for correctness
  especially when we get to all maintainers' contributions (in a separate PR).
- The commits API does not (yet?) support trailers or commit "committer"s, just
  authors.
2023-02-20 23:24:54 +00:00
Mike McQuaid
37b4780037
dev-cmd/contributions: fix spacing.
Otherwise this fails the documentation lint.
2023-02-20 16:16:08 +00:00
Issy Long
04e476eb84
dev-cmd/contributions: Add --repositories=brew,core,cask shorthand
- For annual "has this person contributed enough", we focus on the main
  Homebrew repos: brew, core and cask. Let's make that easier than
  `--repositories=brew,core,cask`.
2023-02-19 18:36:13 +00:00
Issy Long
43a88cbd97
dev-cmd/contributions: Appease RuboCop 2023-02-15 14:04:05 +00:00
Issy Long
44edad85bc
dev-cmd/contributions: Add a grand total row to the CSV
```
$ brew contributions issyl0 --csv
The user issyl0 has made 1203 contributions in all time.
user,repo,commits,coauthorships,signoffs,total
issyl0,brew,333,13,0,346
issyl0,core,473,24,326,823
issyl0,cask,4,0,0,4
issyl0,aliases,0,0,0,0
issyl0,autoupdate,1,0,0,1
issyl0,bundle,14,2,0,16
issyl0,command-not-found,1,0,0,1
issyl0,test-bot,3,0,0,3
issyl0,services,9,0,0,9
issyl0,cask-drivers,0,0,0,0
issyl0,cask-fonts,0,0,0,0
issyl0,cask-versions,0,0,0,0
issyl0,*,*,*,*,1203
```
2023-02-15 14:00:05 +00:00
Issy Long
9aad9d011b
dev-cmd/contributions: Add a per-repo total column to the CSV
```
$ brew contributions issyl0 --csv
The user issyl0 has made 1202 contributions in all time.
user,repo,commits,coauthorships,signoffs,total
issyl0,brew,332,13,0,345
issyl0,core,473,24,326,823
issyl0,cask,4,0,0,4
issyl0,aliases,0,0,0,0
issyl0,autoupdate,1,0,0,1
issyl0,bundle,14,2,0,16
issyl0,command-not-found,1,0,0,1
issyl0,test-bot,3,0,0,3
issyl0,services,9,0,0,9
issyl0,cask-drivers,0,0,0,0
issyl0,cask-fonts,0,0,0,0
issyl0,cask-versions,0,0,0,0
```
2023-02-15 13:58:49 +00:00
Issy Long
2719c345ab
dev-cmd/contributions: CSV output of queried repos; shorter sentence
- This gives users of this command a `--csv` option to pass to... you guessed
  it, generate a CSV that's `pbcopy`able elsewhere, for more granular
  breakdowns of where a person contributed.
- Inspiration was taken from the mockup in
  https://github.com/Homebrew/brew/issues/13642#issuecomment-1254535251
  but without the extra dependency of the TerminalTable gem.
- Always print a condensed "total contributions" sentence.

Output:

```
$ brew contributions issyl0
The user issyl0 has made 1201 contributions in all time.

$ brew contributions issyl0 --csv
user,repo,commits,coauthorships,signoffs
issyl0,brew,331,13,0
issyl0,core,473,24,326
issyl0,cask,4,0,0
issyl0,aliases,0,0,0
issyl0,autoupdate,1,0,0
issyl0,bundle,14,2,0
issyl0,command-not-found,1,0,0
issyl0,test-bot,3,0,0
issyl0,services,9,0,0
issyl0,cask-drivers,0,0,0
issyl0,cask-fonts,0,0,0
issyl0,cask-versions,0,0,0
```
2023-02-15 12:47:10 +00:00
Issy Long
abe23fb249
dev-cmd/contributions: Add up different contribution types for a total
❯ brew contributions mikemcquaid
mikemcquaid directly authored 23766 commits, co-authored 241 commits, and signed-off 6730 commits across all Homebrew repos in all time. Total: 30737.
2023-02-14 10:51:13 +00:00