Commit e0ba7b8e authored by Edward Lemur's avatar Edward Lemur Committed by LUCI CQ

gclient: Fix auto-fetching refs.

gclient executes `git rev-parse <ref>` to check if <ref>
already exists in the local clone, which succeeds when
<ref> is a git revision hash, even if it doesn't exist.

We execute `git rev-parse <ref>^{commit}` instead, which only
succeeds when <ref> resolves to a valid commit in the local
repo.

Change-Id: Ia1cdf7162c4c82a7e4214c6af375c1a9522d7b07
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2095745Reviewed-by: 's avatarJosip Sokcevic <sokcevic@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent d52eddaa
......@@ -1374,9 +1374,7 @@ class GitWrapper(SCMWrapper):
"""Attempts to fetch |revision| if not available in local repo.
Returns possibly updated revision."""
try:
self._Capture(['rev-parse', revision])
except subprocess2.CalledProcessError:
if not scm.GIT.IsValidRevision(self.checkout_path, revision):
self._Fetch(options, refspec=revision)
revision = self._Capture(['rev-parse', 'FETCH_HEAD'])
return revision
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment