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?

https://github.com/bazelbuild/bazel/commit/4f51c0849305e9bfff2af4d80792fc69c02dfa08#diff-837a9f01631c2638001dbb9c581868ad

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

Most upvoted comments

Looks good now. 👌

So, testing the git commands manually, I see the same error:

jcater@jcater:~/repos$ git clone --depth=1 git@github.com:wix-playground/repoB.git
Cloning into 'repoB'...
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 5 (delta 0), reused 4 (delta 0), pack-reused 0
Receiving objects: 100% (5/5), done.
jcater@jcater:~/repos$ cd repoB/
jcater@jcater:~/repos/repoB:master$ git reset --hard 735e089f501c182560c4df2451bd16011fd09113
fatal: Could not parse object '735e089f501c182560c4df2451bd16011fd09113'.

If I remove the --depth=1 flag from the git clone command, then the git 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.