mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 18:51:29 +00:00
Make sure _UpdateMirrorIfNotContains fetches the specified revision
_UpdateMirrorIfNotContains populates the mirror if a given rev isn't found in the mirror, but if this rev is invalid, it's never fetched at all. Check that we've actually fetched it after populating the mirror. Bug: 407864212 Change-Id: Id66695636e749c4f7372aa522ab03ec4ec8feb52 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6441962 Reviewed-by: Josip Sokcevic <sokcevic@chromium.org> Commit-Queue: Gavin Mak <gavinmak@google.com>
This commit is contained in:
@@ -1330,9 +1330,11 @@ class GitWrapper(SCMWrapper):
|
||||
return git_cache.Mirror(url, **mirror_kwargs)
|
||||
|
||||
def _UpdateMirrorIfNotContains(self, mirror, options, rev_type, revision):
|
||||
"""Update a git mirror by fetching the latest commits from the remote,
|
||||
unless mirror already contains revision whose type is sha1 hash.
|
||||
"""
|
||||
"""Update a git mirror unless it already contains a hash revision.
|
||||
|
||||
This raises an error if a hash revision isn't present even after
|
||||
fetching from the remote.
|
||||
"""
|
||||
if rev_type == 'hash' and mirror.contains_revision(revision):
|
||||
if options.verbose:
|
||||
self.Print('skipping mirror update, it has rev=%s already' %
|
||||
@@ -1349,6 +1351,10 @@ class GitWrapper(SCMWrapper):
|
||||
depth=depth,
|
||||
lock_timeout=getattr(options, 'lock_timeout', 0))
|
||||
|
||||
# Make sure we've actually fetched the revision we want.
|
||||
if rev_type == 'hash' and not mirror.contains_revision(revision):
|
||||
raise gclient_utils.Error(f'Failed to fetch {revision}.')
|
||||
|
||||
def _Clone(self, revision, url, options):
|
||||
"""Clone a git repository from the given URL.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user