Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0.0] Make git_repository() ignore GIT_ env vars #24300

Merged
merged 1 commit into from
Nov 13, 2024

Conversation

bazel-io
Copy link
Member

This ensures that this repository rule cannot be influenced by these environment variables, particularly GIT_DIR, keeping the operation limited to the directory specified by the repository_ctx.

In particular, this ensures that calling Bazel (e.g. bazel test) from within a Git hook will work reliably. Git hooks set GIT_DIR (among others), which can cause the repository rule's invocations of git to misbehave. https://git-scm.com/docs/githooks

When using Git worktrees and calling Bazel from a Git hook, it has been observed that git_repository() will not only fail, but will also set core.bare = true, breaking the user's clone.

Fixes #24199.

Closes #24204.

PiperOrigin-RevId: 695642299
Change-Id: Id81e32194117cd8996408b236a6a88a20b14910b

Commit 89115d9

This ensures that this repository rule cannot be influenced by these environment variables, particularly `GIT_DIR`, keeping the operation limited to the directory specified by the `repository_ctx`.

In particular, this ensures that calling Bazel (e.g. `bazel test`) from within a Git hook will work reliably. Git hooks set `GIT_DIR` (among others), which can cause the repository rule's invocations of `git` to misbehave. https://git-scm.com/docs/githooks

When using Git worktrees and calling Bazel from a Git hook, it has been observed that `git_repository()` will not only fail, but will also set `core.bare = true`, breaking the user's clone.

Fixes bazelbuild#24199.

Closes bazelbuild#24204.

PiperOrigin-RevId: 695642299
Change-Id: Id81e32194117cd8996408b236a6a88a20b14910b
@bazel-io bazel-io requested a review from a team as a code owner November 12, 2024 21:19
@bazel-io bazel-io added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Nov 12, 2024
@iancha1992 iancha1992 enabled auto-merge November 12, 2024 21:20
@iancha1992 iancha1992 added this pull request to the merge queue Nov 13, 2024
Merged via the queue into bazelbuild:release-8.0.0 with commit 624d4d9 Nov 13, 2024
46 checks passed
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Nov 13, 2024
@Wyverald Wyverald deleted the cp24204-8.0.0 branch November 15, 2024 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants