94 Commits

Author SHA1 Message Date
Bo Anderson
eb5f47637f
Globally silence default gem warnings 2024-09-05 03:37:25 +01:00
Issy Long
9e98bbf59a
Revert "dev-cmd/contributions: Show only the CSV output for --csv" 2024-07-28 19:28:19 +01:00
Issy Long
c880dd4350
dev-cmd/contributions: Show only the CSV output for --csv
- This was noisy when using `--csv` as it would print the text output
  and then the CSV output.
2024-07-28 16:17:07 +01:00
Sam Ford
a6e61fd664
contributions, github: reorder requires
Per feedback to https://github.com/Homebrew/brew/pull/17806, this
moves some `require` statements in `dev-cmd/contributions.rb` and
`Utils::GitHub` into the methods that need them.
2024-07-25 10:02:18 -04:00
Sam Ford
403b0bf3f1
contributions: resolve type errors
This updates the type signature for `#scan_repositories` to address a
runtime type error and to reflect the actual return type.

The logic in `#scan_repositories` to check for unsupported
repositories leads to a type error, as `#ofail` has a void return
type. To resolve this, I moved the repository verification code into
`#run` (after `repos` is defined but before it's used) and used
`#odie`, so the command will exit early with an error.

While I was at it, I updated the type for the `repos` parameter to
not be `nilable`, as it shouldn't be `nil` based on how we're
handling `repos` in `#run`.
2024-07-18 15:40:10 -04:00
Sam Ford
b4b984e968
contributions: move CSV require into #generate_csv
CSV generation is optional, so this moves the related `require` into
the method where `CSV` is used (following a pattern we've used for
other `require` calls throughout `brew`).
2024-07-18 15:40:07 -04:00
Sam Ford
a9f7da36e0
contributions, github: add missing requires
This resolves `unitialized constant` errors in `brew contributions`
(`Tap`, `GitHub`) and `Utils::GitHub` (`Utils::Curl`).

This also preemptively adds some requires to `Utils::GitHub` and
`GitHub::API`, to avoid similar errors.
2024-07-18 12:55:41 -04:00
Issy Long
3d09094df0
Fewer T.musts 2024-07-02 16:20:39 +01:00
Issy Long
9130dd1210
dev-cmd/contributions: Tighten up type sigs 2024-07-01 23:49:31 +01:00
Issy Long
c57cd4bf98
dev-cmd/contributions: Bump to Sorbet typed: strict 2024-06-30 18:42:16 +01:00
Issy Long
da78bcfdcc
dev-cmd/contributions: ‘Coauthorship’ sounds weird
- This inconsistency of "author", "committer", "coauthorship", that is, only "coauthor" ending in "ship", has annoyed me ever since I wrote it. It has finally sufficiently annoyed me to fix it.
2024-06-02 08:35:33 +01:00
Issy Long
1f9c764a69
dev-cmd/contributions: Pass from correctly through count_reviews too 2024-05-28 14:10:25 +01:00
Issy Long
808cfda92d
dev-cmd/contributions: Fix the date range behaviour
- This was broken (I did have a commit SHA for the breakage but I can't find it now) since `from` and `args.from` are different variables (one can be nil, the other has a default value).
- So it was reporting very high counts because, despite the message, the `from` restriction was not being passed to `count_repo_commits`.
2024-05-28 13:58:41 +01:00
Mike McQuaid
a408da65fc
Hide default gems warnings for Ruby 3.4.
These omit warnings with Ruby 3.3 and are required for Ruby 3.4. We'll
fix them when we're upgrading to 3.4 instead.
2024-05-17 14:42:44 +09:00
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