Skip to content

formula: provide fallback git identity in sandbox - #24066

Merged
MikeMcQuaid merged 3 commits into
mainfrom
sandbox-git-identity
Sep 22, 2026
Merged

MikeMcQuaid merged 3 commits into
mainfrom
sandbox-git-identity

Conversation

@Moisan

@Moisan Moisan commented Sep 22, 2026

Copy link
Copy Markdown
Member

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Used Claude Code (Claude Fable 5.1) to help understand the source of the problem and draft the code. Reviewed manually.


Sandboxed brew test nulls GIT_CONFIG_GLOBAL, so a test that runs git commit without configuring user.name and user.email relies on git auto-detecting an identity from the hostname. With deny_network_access! that hostname lookup is blocked, so git fails with "unable to auto-detect email address" on any machine whose hostname needs DNS to resolve. For example, brew test sem-cli fails locally. I attempted a fix for sem-cli, but realized the root cause was the sandbox.

CI never spotted this because brew test-bot exports HOMEBREW_GIT_NAME and HOMEBREW_GIT_EMAIL before running any test.

This PR changes the sandbox by adding .gitconfig with a fallback user.name and user.email in their isolated HOME, and GIT_CONFIG_GLOBAL points at that file instead of /dev/null.

Copilot AI lite review requested due to automatic review settings September 22, 2026 02:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The regression test should verify both fallback identity fields before approval.

Review effort: Lite
Findings: None

What changed in this PR

Adds a sandbox-local fallback Git identity so formula tests can commit without hostname-based identity detection.

Changes:

  • Creates an isolated .gitconfig with fallback name and email.
  • Points sandboxed Git operations to that configuration.
  • Adds regression coverage for the fallback identity.
File Summary
Library/​Homebrew/​test/​formula_spec.rb Tests fallback Git identity and sandbox environment behavior.
Library/​Homebrew/​formula.rb Creates and uses the isolated Git configuration.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread Library/Homebrew/formula.rb Resolved

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now thanks!

@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Sep 22, 2026
Merged via the queue into main with commit 3f12c3e Sep 22, 2026
51 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the sandbox-git-identity branch September 22, 2026 16:24
wincent added a commit to wincent/wincent that referenced this pull request Sep 25, 2026
Homebrew has this fascinating wart wherein if you ever run a "developer"
command, it persists a flag and then assumes you want to track `HEAD` of
`main` from there on.

Fortunately, the manpage (https://docs.brew.sh/Manpage) documents an
environment variable which will apparently avoid this:

> HOMEBREW_UPDATE_TO_TAG
>
>     If set, always use the latest stable tag (even if developer
>     commands have been run).

From there, getting back to a released version can be done with:

```
brew developer off
HOMEBREW_UPDATE_TO_TAG=1 brew update --force
```

It may still print "Already up-to-date" because it's doing a `git
fetch`, but it will actually update the checkout to point at a
released/tagged version, which you can verify with `brew --version`:

```
$ brew --version # before
Homebrew 7.0.6-42-gddc6726
$ brew --version # after
Homebrew 7.0.6
$ git -C /opt/homebrew branch --show-current
stable
```

For context, the reason why I discovered this is that my Homebrew update
today started running afoul of new sandboxing changes that are actively
being iterated on:

- Homebrew/brew#24034
  ("sandbox: keep system temp dirs writable in offline installs",
  2026-09-19)
- Homebrew/brew@c9bfdc3
  ("Extend sandboxing to package processing", 2026-09-21)
- Homebrew/brew#24066
  ("formula: provide fallback git identity in sandbox", 2026-09-22)
- Homebrew/brew@d2b5dc5
  ("Relax Git download credential sandboxing", 2026-09-23)
- Homebrew/brew@c574884
  ("Restore PATH for sandboxed Git downloads", 2026-09-24)

I'd rather not go along for the ride of every intermediate broken state,
so hopefully this keeps me on tagged/released versions from here on.

Change-Id: nuvqzxwlypyplxqwqmvtzllltzmktlxt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

⌂ 换网址