bazel: git_repository skylark rule regression in bazel 0.10.0rc7
Description of the problem / feature request:
git_repository pointing at a commit which is not the latest commit in the repo causes error because of git clone --depth 1
. This is currently blocking us from upgrading to bazel 0.10.0.
Bugs: what’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Clone https://github.com/wix-playground/repoA
Run bazel build //...
(with 0.10.0rc7)
Note this line points at a non-HEAD commit of repoB.
What operating system are you running Bazel on?
MacOS 10.12.6 & Debian8
What’s the output of bazel info release
?
release 0.10.0rc7
Have you found anything relevant by searching the web?
Any other information, logs, or outputs that you want to share?
▶ bazel build //...
ERROR: error loading package '': Encountered error while reading extension file 'whatever.bzl': no such package '@repoB//': Traceback (most recent call last):
File "/private/var/tmp/_bazel_alonbl/46478dd6ac03b1b47726754e0c4e0fa0/external/bazel_tools/tools/build_defs/repo/git.bzl", line 69
_clone_or_update(ctx)
File "/private/var/tmp/_bazel_alonbl/46478dd6ac03b1b47726754e0c4e0fa0/external/bazel_tools/tools/build_defs/repo/git.bzl", line 44, in _clone_or_update
fail(("error cloning %s:\n%s" % (ctx....)))
error cloning repoB:
+ cd /private/var/tmp/_bazel_alonbl/46478dd6ac03b1b47726754e0c4e0fa0/external
+ rm -rf /private/var/tmp/_bazel_alonbl/46478dd6ac03b1b47726754e0c4e0fa0/external/repoB
+ git clone --depth=1 git@github.com:wix-playground/repoB.git /private/var/tmp/_bazel_alonbl/46478dd6ac03b1b47726754e0c4e0fa0/external/repoB
Cloning into '/private/var/tmp/_bazel_alonbl/46478dd6ac03b1b47726754e0c4e0fa0/external/repoB'...
+ cd /private/var/tmp/_bazel_alonbl/46478dd6ac03b1b47726754e0c4e0fa0/external/repoB
+ git reset --hard 735e089f501c182560c4df2451bd16011fd09113
fatal: Could not parse object '735e089f501c182560c4df2451bd16011fd09113'.
+ git fetch --depth=1 origin 735e089f501c182560c4df2451bd16011fd09113:735e089f501c182560c4df2451bd16011fd09113
ERROR: error loading package '': Encountered error while reading extension file 'whatever.bzl': no such package '@repoB//': Traceback (most recent call last):
File "/private/var/tmp/_bazel_alonbl/46478dd6ac03b1b47726754e0c4e0fa0/external/bazel_tools/tools/build_defs/repo/git.bzl", line 69
_clone_or_update(ctx)
File "/private/var/tmp/_bazel_alonbl/46478dd6ac03b1b47726754e0c4e0fa0/external/bazel_tools/tools/build_defs/repo/git.bzl", line 44, in _clone_or_update
fail(("error cloning %s:\n%s" % (ctx....)))
error cloning repoB:
+ cd /private/var/tmp/_bazel_alonbl/46478dd6ac03b1b47726754e0c4e0fa0/external
+ rm -rf /private/var/tmp/_bazel_alonbl/46478dd6ac03b1b47726754e0c4e0fa0/external/repoB
+ git clone --depth=1 git@github.com:wix-playground/repoB.git /private/var/tmp/_bazel_alonbl/46478dd6ac03b1b47726754e0c4e0fa0/external/repoB
Cloning into '/private/var/tmp/_bazel_alonbl/46478dd6ac03b1b47726754e0c4e0fa0/external/repoB'...
+ cd /private/var/tmp/_bazel_alonbl/46478dd6ac03b1b47726754e0c4e0fa0/external/repoB
+ git reset --hard 735e089f501c182560c4df2451bd16011fd09113
fatal: Could not parse object '735e089f501c182560c4df2451bd16011fd09113'.
+ git fetch --depth=1 origin 735e089f501c182560c4df2451bd16011fd09113:735e089f501c182560c4df2451bd16011fd09113
INFO: Elapsed time: 5.505s
FAILED: Build did NOT complete successfully (0 packages loaded)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 29 (26 by maintainers)
Commits related to this issue
- Change git clone to pull all history, so all needed commits can be accessed. Fixes #4537. Change-Id: I28afcbc89e230e319788c2426e57d43c1ad5dfee PiperOrigin-RevId: 183827742 — committed to bazelbuild/bazel by katre 6 years ago
- Change git clone to pull all history, so all needed commits can be accessed. Fixes #4537. Change-Id: I28afcbc89e230e319788c2426e57d43c1ad5dfee PiperOrigin-RevId: 183827742 — committed to bazelbuild/bazel by katre 6 years ago
- Change git clone to pull all history, so all needed commits can be accessed. Fixes #4537. Change-Id: I28afcbc89e230e319788c2426e57d43c1ad5dfee PiperOrigin-RevId: 183827742 — committed to bazelbuild/bazel by katre 6 years ago
- Change git clone to pull all history, so all needed commits can be accessed. Fixes #4537. Change-Id: I28afcbc89e230e319788c2426e57d43c1ad5dfee PiperOrigin-RevId: 183827742 — committed to werkt/bazel by katre 6 years ago
Looks good now. 👌
So, testing the git commands manually, I see the same error:
If I remove the
--depth=1
flag from thegit clone
command, then thegit reset
works. It looks like this was added in 512b9b9b353bcabc436a87329fadd449c684c44b.I’ll take a look at a quick fix, and if that doesn’t work I’ll see if we can revert the commit entirely.