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

git_repository is not reproducible #18152

Closed
cameron-martin opened this issue Apr 20, 2023 · 3 comments
Closed

git_repository is not reproducible #18152

cameron-martin opened this issue Apr 20, 2023 · 3 comments
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@cameron-martin
Copy link
Contributor

cameron-martin commented Apr 20, 2023

Description of the bug:

The git_repository repository rule leaves the .git directory, either in the root or in .tmp_git_root. This directory contains files that are not a function of the input attributes, for example .git/logs contains files that contain timestamps of when the remote branch was fetched.

This causes a real issue in rules_rust (bazelbuild/rules_rust#1927), since it generates targets that glob the entire external repository.

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Create a git_repository repository rule, inspect the .git/logs directory and see that it contains timestamps.

Which operating system are you running Bazel on?

Ubuntu 22.04

What is the output of bazel info release?

release 6.1.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@Pavank1992 Pavank1992 added the team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. label Apr 20, 2023
@meteorcloudy meteorcloudy added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Apr 25, 2023
@sluongng
Copy link
Contributor

Does it not remove it here

ctx.delete(ctx.path(".git"))
🤔

@cameron-martin
Copy link
Contributor Author

I guess this bug only happens when strip_prefix is specified, and the git repository is in .tmp_git_root. I didn't observe the other case, and just assumed. I think the line above needs to be changed to:

if ctx.attr.strip_prefix:
    ctx.delete(ctx.path(".tmp_git_root"))
else:
    ctx.delete(ctx.path(".git"))

@fmeum
Copy link
Collaborator

fmeum commented Apr 28, 2023

@cameron-martin That looks very reasonable. Do you want to submit that as a PR?

cameron-martin added a commit to cameron-martin/bazel that referenced this issue Apr 29, 2023
…using strip_prefix

Leaving the `.git` directory in an external repository makes the rule not reproducible, since this directory contains timestamps of when the fetch occurred. When strip_prefix is not specified, this directory is correctly cleaned up but not when strip_prefix is specified, since the `.git` directory lives in `.tmp_git_root`.

Note that we cannot delete the whole `.tmp_git_root` directory, since the items in the root are symlinks to here.

Fixes bazelbuild#18152.
fweikert pushed a commit to fweikert/bazel that referenced this issue May 25, 2023
…using strip_prefix

Leaving the `.git` directory in an external repository makes the rule not reproducible since this directory contains timestamps of when the fetch occurred. When strip_prefix is not specified, this directory is correctly cleaned up but not when strip_prefix is specified, since the `.git` directory lives in `.tmp_git_root`.

Note that we cannot delete the whole `.tmp_git_root` directory, since the items in the root are symlinks to here.

Fixes bazelbuild#18152.

Closes bazelbuild#18271.

PiperOrigin-RevId: 528962539
Change-Id: I03b0ee6e6b5464af2d28eb6dc05fb6e6f33afaa3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
7 participants