Commit 61a1b5f3 authored by Michael Spang's avatar Michael Spang Committed by Commit Bot

Avoid unnecessary invocations of "git fetch"

If we already have the correct commit, it is not necessary to fetch.  Any
fetches can takes minutes due to gerrit problems, and often fail
completely, so it is helpful to avoid them completely whenever we can.

Bug: 938627

Change-Id: I54494cad9b9aa0090f51674b6b9f56bb3e842f12
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1504102
Commit-Queue: Michael Spang <spang@chromium.org>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
parent 0668403d
......@@ -652,14 +652,18 @@ class GitWrapper(SCMWrapper):
raise gclient_utils.Error('Invalid Upstream: %s' % upstream_branch)
self._SetFetchConfig(options)
self._Fetch(options, prune=options.force)
# Fetch upstream if we don't already have |revision|.
if not scm.GIT.IsValidRevision(self.checkout_path, revision, sha_only=True):
# Update the remotes first so we have all the refs.
remote_output = scm.GIT.Capture(['remote'] + verbose + ['update'],
cwd=self.checkout_path)
if verbose:
self.Print(remote_output)
self._Fetch(options, prune=options.force)
if not scm.GIT.IsValidRevision(self.checkout_path, revision,
sha_only=True):
# Update the remotes first so we have all the refs.
remote_output = scm.GIT.Capture(['remote'] + verbose + ['update'],
cwd=self.checkout_path)
if verbose:
self.Print(remote_output)
revision = self._AutoFetchRef(options, 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