71 Commits

Author SHA1 Message Date
Carlo Cabrera
1fbe4366a0
Support setting GIT_COMMITTER_NAME and GIT_COMMITTER_EMAIL
Our autobump workflow sets the author and committer to the user who
triggered the workflow, defaulting to @BrewTestBot for scheduled runs.

This can be confusing for maintainers when GitHub shows up as
"Unverified" because the commit is signed with @BrewTestBot's key.[^1]

Let's fix that by configuring our autobump workflow to always commit as
@BrewTestBot, so that the committer matches the GPG signature. To do
that, we need to add support for setting `GIT_COMMITTER_NAME` and
`GIT_COMMITTER_EMAIL`.

[^1]: See, for example, Homebrew/homebrew-core#197234.
2024-11-11 18:45:38 +08:00
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Mike McQuaid
ea2892f8ee
brew.rb: handle missing args. 2024-03-07 16:20:20 +00:00
Douglas Eichelberger
eb7c3e52a0 Require SystemInclude only where needed 2024-01-31 11:42:01 -08:00
Mike McQuaid
7da934f7e2
Deprecate/disable/delete code.
The next release after this is merged will be 4.1.0.

Co-authored-by: Markus Reiter <me@reitermark.us>
2023-07-06 16:56:20 +01:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Douglas Eichelberger
b90897e280 Create git_repo attr 2023-04-15 19:35:13 -07:00
Douglas Eichelberger
429f23dcc6 Create GitRepoPath 2023-04-15 19:35:12 -07:00
Douglas Eichelberger
827fc87cde Enable more typing 2023-03-15 14:29:15 -07:00
Douglas Eichelberger
f4c9a96c70 Enable types in dev-cmd 2023-03-14 08:32:03 -07:00
Harry Marr
49e2cf9f92
Extract supports_partial_clone_sparse_checkout? 2022-10-20 15:45:33 -04:00
Bo Anderson
02164a35db
Use ORIGINAL_PATHS over envs; reject nil PATH 2022-06-17 19:47:57 +01:00
XuehaiPan
d1aac8857a tests/utils/git_spec: update tests for ensure_formula_installed! 2021-11-24 00:30:26 +08:00
XuehaiPan
3376479e95 utils: add method ensure_formula_installed! 2021-11-23 22:48:39 +08:00
Bo Anderson
36a57aa738
utils/git: remove external dependency loading 2021-10-07 14:51:52 +01:00
Mike McQuaid
7ec024e090
utils/git: require formula.
This is currently causing `brew vendor-gems` to fail.
2021-10-07 11:23:55 +01:00
Bo Anderson
30b24cf4ad
Use HOMEBREW_CURL universally, including formulae 2021-10-04 02:03:04 +01:00
Mike McQuaid
d6957a3acb
Homebrew 3.0.0 deprecations/disables 2021-01-29 19:50:24 +00:00
Mike McQuaid
a1c97c8f3b
utils/git: quieter git --version.
Let's avoid printing this unless `--debug` (to avoid
`brew bundle check -v` outputting this).

Fixes https://github.com/Homebrew/homebrew-bundle/issues/865
2021-01-06 08:51:11 +00:00
Mike McQuaid
74fb058c7e
More deprecations
More deprecations, disabling and removal for Homebrew 2.7.0.
2020-12-18 14:17:37 +00:00
Jonathan Chang
8b206dfa33 git_extensions: move commit_message from utils/git 2020-12-06 14:33:23 +11:00
Jonathan Chang
92d3eda914 git_extensions: move origin_branch from utils/git 2020-12-06 14:33:23 +11:00
Jonathan Chang
d802b3755a utils/git: remove redundant current_branch 2020-12-06 14:33:23 +11:00
Jonathan Chang
75be0ca4d0 git_repository: add type signatures and comments 2020-12-06 14:33:23 +11:00
Mike McQuaid
4f3c590873
Unify and use Git username/email/GPG handling.
We're using essentially the same logic to setup Git for committing in
multiple places but the way we're doing so is inconsistent. Moved to
using two shared utility methods and use them consistently.
2020-11-02 12:21:18 +00:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Jonathan Chang
cdfb1badcf utils/git: helper function to get commit msg 2020-09-20 13:23:01 +10:00
Jonathan Chang
d09ebf428f utils/git: new file_at_commit function 2020-09-20 13:21:27 +10:00
Jonathan Chang
04687aef93 dev-cmd/pr-pull: don't assume a master branch 2020-09-20 13:21:27 +10:00
Jonathan Chang
3a8bd8514f utils/git: add cherry-pick function 2020-09-17 17:27:38 +10:00
Jonathan Chang
49d2e4cbab utils/git: modernize 2020-09-17 17:27:38 +10:00
Seeker
be92ef2889 utils/git: add origin_branch 2020-09-08 08:26:05 -07:00
Markus Reiter
0129247391 Refuse to install Git if HOMEBREW_TEST_GENERIC_OS is set. 2020-08-29 21:45:51 +02:00
Markus Reiter
a6bd784f55 Unset HOMEBREW_TEST_GENERIC_OS when installing Git. 2020-08-26 06:34:30 +02:00
Markus Reiter
677600014e Call clear_available_cache after installing Git. 2020-08-24 05:25:48 +02:00
Markus Reiter
3118fedab9 Refactor and document Git. 2020-08-23 06:40:07 +02:00
Issy Long
2c3b2f68cd
Revert #7933 ("sorbet: set utils/git.rb to true")
- My refactoring of #7933 went wrong in that the tests passed for `brew
  extract` and my manual testing, but both forgot about third-party taps
  exist, so that functionality broke as follows (courtesy of Misty).

  Before:

  ```
  # Git.last_revision_commit_of_files("/usr/local/Homebrew", ["LICENSE.txt", "README.md"])
  => ["ac0665d", ["README.md"]]
  ```

  After:

  ```
  # Git.last_revision_commit_of_files("/usr/local/Homebrew", ["LICENSE.txt", "README.md"])
  => [nil, []]
  ```

- While we think about how to do splats in Sorbet, revert this so
  that users are able to `brew extract` from third party taps again.

- A TODO for later in a separate PR is to write a test for `brew
  extract` that tests the behaviour of third-party taps.

---

- Reverted this manually because the GitHub UI couldn't do it.
- Arguably I didn't need to remove the RBI file, but it's easier to have
  everything gone for now and then revert this revert in future once we
  have a strategy for dealing with splats in Sorbet than have
  inconsistency.
2020-07-09 08:18:38 +01:00
vidusheeamoli
76a2e69990 sorbet: set utils/git.rb to true
(cherry picked from commit 44a04adb1de430066af73a65766eb644c0f5bd41)
2020-07-08 22:34:26 +05:30
Mike McQuaid
3381cbf5c7
Use Homebrew::EnvConfig. 2020-04-07 09:58:26 +01:00
Mike McQuaid
f31e01c3ad
test: set Git name and email.
Extract the code from `bottle.rb` into `utils/git.rb` and ensure it's
run before we run tests.

Should resolve issues like in
https://github.com/Homebrew/homebrew-core/pull/50328
2020-02-17 19:40:44 +00:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
kiendang
028b8b408d Remove use of bash 2019-03-20 20:19:33 +08:00
kiendang
00f74902d4 Call git log through bash for globstar support 2019-03-18 03:05:30 +08:00
kiendang
6be6bba0be brew extract from all taps 2019-03-17 23:44:35 +08:00
Markus Reiter
5dd571adeb Replace #chuzzle with ActiveSupport’s #presence. 2018-10-07 23:10:56 +02:00
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Maxim Belkin
f984701c29
append ? to git_remote_exist 2018-03-14 16:30:45 -05:00
Viktor Oreshkin
461bb20b7c utils/git: use exact format for last_revision_*
Format for oneline can be overridden in user's gitconfig. If that's the
case, last_revision_commit_of_file won't work properly, and because of
that last_revision_of_file won't work at all.

Here's what I was getting when running brew tests:

       expected: "6bec2de"
            got: "\e[33m6bec2dee633f\e[m"

I have abbrev length set to 12, and oneline formatting is more colorful.

So, instead of relying on overrideable format, it should rather specify
"--format=%h" to get only hash, and speciy --abbrev=7 to force abbrev
length to be 7

After this commit tests are passing for me.
2018-03-12 14:07:00 +03:00
Mike McQuaid
83cca40fc9 RuboCop 0.53.0 manual fixes. 2018-03-08 14:10:02 +00:00