1194 Commits

Author SHA1 Message Date
Issy Long
0701ea42fa
cask/audit: Pass a URL's referer through to cURL
- Some casks have URL arguments like "referer" (spelled wrong, that's
  intentional in the HTTP spec).
- The audit for one such cask, `iThoughtsX`, was failing because the
  "referer" wasn't getting passed through to cURL so the access would
  404.

----

Before:

```
❯ brew audit --cask --online --appcast --signing 'ithoughtsx'
[...]
audit for ithoughtsx: failed
 - The binary URL https://cdn.toketaware.com?download=iThoughtsX.zip is not reachable (HTTP status code 404)
 - Version '9.2.0' differs from '9.3.0' retrieved by livecheck.
 - Version '9.2.0' differs from '9.3.0' retrieved by livecheck.
Error: 2 problems in 1 cask detected
```

After:

```
❯ brew audit --cask --online --appcast --signing 'ithoughtsx'
[...]
audit for ithoughtsx: failed
 - Version '9.2.0' differs from '9.3.0' retrieved by livecheck.
 - Version '9.2.0' differs from '9.3.0' retrieved by livecheck.
Error: 1 problem in 1 cask detected
```
2023-03-16 23:28:50 +00:00
Douglas Eichelberger
f4c9a96c70 Enable types in dev-cmd 2023-03-14 08:32:03 -07:00
Issy Long
cace5c429f
rubocop: Enable Style/AccessorGrouping and autofix offenses
- With RuboCop 1.48.1 this no longer reports offenses and applies bugged
  autocorrections for `attr`s with Sorbet `sig`s, so we can enable it.
2023-03-14 00:01:02 +00:00
Issy Long
8e13a6e1f4
Merge pull request #14944 from issyl0/more-rubocop-naming-method-parameter-name
rubocop: Further trim `Naming/MethodParameterName` allowlist
2023-03-11 22:59:39 +00:00
Issy Long
e9d994622e
rubocop: Drop "f" from Naming/MethodParameterName allowlist
- This either stands for "file" but more often than not "formula".
2023-03-11 00:17:27 +00:00
Douglas Eichelberger
9446db7720 Typecheck some utils 2023-03-09 21:46:35 -08:00
Douglas Eichelberger
02fd0422aa Enable typing in a few more files 2023-03-09 13:42:06 -08:00
Issy Long
2814d2285a
Make str variable names longer
- Three characters is the RuboCop limit for parameter names, but more
  descriptive is good.
- Requested in
  https://github.com/Homebrew/brew/pull/14922#pullrequestreview-1330848594,
  but the automerge was too quick for me to get to it.
2023-03-08 15:30:25 +00:00
Issy Long
89fb8c78e8
rubocop: Drop "s" from Naming/MethodParameterName allowlist
- Most usages of this were in the `pretty_duration` method, where "s"
  is better described as "seconds" since we're calculating a duration.
- I also took the executive decision to do the same to "m" which refers
  to "minutes".
2023-03-08 14:42:53 +00:00
Issy Long
1295904986
sorbet: Autogenerate the RBI file for utils/tty.rb
- Sort of. It's not via Parlour, because I read the docs and all it says
  about dynamically generating things is "of course it's better to do
  that", no examples. I tried my best, but Bo's work on `attr.rb` was
  mind-boggling.
- Instead, let's add a simple but functional generator script that I
  actually understand, as an alternative to maintaining these RBI files
  for dynamic methods manually, so that we can get rid of some use of
  `srb rbi hidden-definitions` since that's deprecated.
- TODO: Run this script as part of `brew typecheck --update` so it gets
  updated with all the other RBI files periodically.
- Follow up to PR 14651.
2023-03-06 21:46:04 +00:00
Issy Long
6a704f2f40
sorbet: Bump more files to typed: true
- This was done through the `brew typecheck --suggest-typed --update`
  command.
2023-03-05 18:18: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
42c9ad1447
Merge pull request #14860 from issyl0/contributions-commits-committed
dev-cmd/contributions: Count the number of commits a user committed
2023-03-03 17:37:35 +00:00
Douglas Eichelberger
d98b7845d3 Enable typing in misc files 2023-03-03 08:29:26 -08:00
Douglas Eichelberger
a5aef97851 brew style --fix 2023-03-02 11:49:09 -08: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
Mike McQuaid
32463227ac
Deprecate preferred_shell and shell_profile.
I know that we're outside our normal deprecation cycle but: these are
totally broken with the API and it doesn't make sense to support them
only for non-core formulae.
2023-02-28 15:02:06 +00:00
Douglas Eichelberger
f9f73f3ef6 Tidy up 2023-02-27 21:42:47 -08:00
Douglas Eichelberger
7f3593e12d inline titleize 2023-02-27 20:18:10 -08:00
Douglas Eichelberger
2c5067ec77 Port dynamic invocation 2023-02-27 20:18:10 -08:00
Douglas Eichelberger
2c73d4d9b7 Replace deconstantize inflection with util 2023-02-27 20:17:33 -08:00
Douglas Eichelberger
d62211d3af Replace demodulize inflection with util 2023-02-27 20:17:33 -08:00
Douglas Eichelberger
37015b6b08 Change to pluralize, port more call sites 2023-02-27 20:17:33 -08:00
Douglas Eichelberger
0438a3a538 Draft implementation to replace ActiveSupport inflections 2023-02-27 20:17:33 -08:00
Mike McQuaid
6db7732fa3
Merge pull request #14821 from issyl0/support-date-ranges-in-pr-reviews-query
dev-cmd/contributions: Support date ranges in PR reviews query
2023-02-28 00:06:41 +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
214e2102c3
utils/github: Remove unnecessary .delete_prefix("/")
- This workaround was originally added in 2020. I have confirmed with
  https://api.github.com/search/code?q=brew+language%3Aruby+org:Homebrew that
  the `path` string no longer has a leading `/`.
2023-02-26 15:27:02 +00:00
Issy Long
550599d03b
utils/github: Switch check_fork_exists to fork_exists?
- It's Ruby style convention that methods that return only booleans end with a
  question mark.
2023-02-26 15:26:07 +00:00
Issy Long
591afa8ee0
utils/github: Appease brew style line length 2023-02-25 22:27:48 +00:00
Issy Long
99d2bb9a53
utils/github: Use search_results_items method for code search 2023-02-25 22:01:12 +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
Mike McQuaid
e95ce6967a
brew style --fix 2023-02-24 13:50:07 +00:00
Mike McQuaid
d7029e95cd
Merge pull request #14769 from dduugg/enable-types
Enable typing in Cask::Artifact
2023-02-23 18:02:44 +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
dd140ea717
utils/github/api: Smarter pagination in paginate_rest
- The `API_MAX_PAGES` value is 50, so for pages 1 to 50, the
  `paginate_rest` method was making an API call even if there was no
  data past, for example, page 8.
- This made `brew contributions --user=issyl0` take 11 minutes, since we
  made 50 API calls _per repo_ even if it was unnecessary, burning down
  our API allowance.
- Instead, stop looping if we detect that there's no data in `result`.
- This probably needs more testing for other parts of Homebrew that rely
  on `paginate_rest` and the different shapes of data it outputs.
2023-02-22 17:53:46 +00:00
Douglas Eichelberger
29c6baeed1 Enable typing in Cask::Artifact 2023-02-22 09:11:29 -08: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
Mike McQuaid
792ec7fc85
utils/analytics: tweaks constants.
This enables easier usage in `brew formula-analytics`.
2023-02-21 17:07:01 +00:00
Issy Long
c9e6b81b4b
utils/github: API.paginate_rest handles extra query params
- Functionally it doesn't matter that the URL will have an `&` at the
  end if `additional_query_params` is `nil`, because it doesn't affect
  the URL at all.
2023-02-21 11:06:30 +00:00
Mike McQuaid
98d9f28307
Merge pull request #14739 from issyl0/rubocop-disable-all-metrics
rubocop: Entirely disable `Metrics` cops
2023-02-21 09:16:28 +00:00
Mike McQuaid
f0fbeba2ef
Merge pull request #14723 from carlocab/zlib-mtime
utils/gzip: set `mtime = 1` when `mtime == 0`.
2023-02-21 09:04:55 +00:00
Issy Long
298bb65dfb
rubocop: Entirely disable Metrics cops
- These are arbitrary length limits that had a load of disables in code.
- The limits were only increasing over time rather than decreasing.
- Fixing the problematic code to be shorter would take a long time for
  questionable gain since the problem has been around so long.
2023-02-21 00:34:17 +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
Carlo Cabrera
55c75618fc
utils/gzip: set mtime = 1 when mtime == 0.
This allows us to bottle formulae whose source modified time is indeed
`0`.

Needed for Homebrew/homebrew-core#123724.
2023-02-20 22:02:58 +08:00
Mike McQuaid
aaec4014fd
Merge pull request #14710 from issyl0/rubocop-excludes
rubocop: Clean up some `Exclude`s
2023-02-20 09:51:11 +00:00
Mike McQuaid
57844530a9
analytics: remove UUID.
We don't use this at all with InfluxDB and don't need it any more for GA
so let's just remove it.
2023-02-20 09:05:15 +00:00
Issy Long
f8654bd363
rubocop: In-line disables of Metrics/{Module,Block,Class}Length
- We're not going to make the really long things be any shorter any time soon.
- The instructions in issue 14685 say, pragmatically, "disable all the rubocop
  rules we're never going to realistically fix e.g. Metrics/ClassLength". But
  that felt like a slippery slope to more _really_ long modules/classes/blocks,
  and the limits are here for a reason.
2023-02-19 16:33:23 +00:00
Mike McQuaid
ad1213a7da
utils/analytics: make on_request a proper boolean.
Otherwise when it's `false` it's being turned into a `true` value.
2023-02-16 17:51:42 +00:00
Mike McQuaid
a83fef7b41
utils/analytics: cleanup data.
Based on reviewing InfluxDB buckets.
2023-02-16 13:15:04 +00:00
Mike McQuaid
ef8ad10741
utils/analytics: fix BuildError reporting.
Need to ensure we call the correct methods to avoid duplicates.
2023-02-16 12:59:46 +00:00