Commit d88563fa authored by Kirill Smelkov's avatar Kirill Smelkov Committed by Kazuhiko Shiozaki

gitclone: We don't have to fetch, if revision is already present in local git repository

Because revision specifies worktree state exactly, and if we have it
already, we don't need to fetch anything -- it is possible to
checkout/reset to the revision right away.

The reason for this patch is that fetching is sometimes not very fast or
even slow. For example today, gitlab.com had some outage and I've
developed this patch while waiting for it to come back.

/reviewed-by @jerome, @kazuhiko
/reviewed-on !1
parent 7c2259d3
......@@ -34,7 +34,7 @@ import time
import traceback
from zc.buildout import UserError
from subprocess import check_call, CalledProcessError
from subprocess import call, check_call, CalledProcessError
import subprocess
try:
......@@ -244,7 +244,13 @@ class Recipe(object):
# first cleanup pyc files
self.deletePycFiles(self.location)
# then update
# then update,
# but, to save time, only if we don't have the revision already
revision_already_fetched = \
self.revision and \
call([self.git_command, 'rev-parse', '--verify', self.revision],
cwd=self.location) == 0
if not revision_already_fetched:
check_call([self.git_command, 'fetch', '--all'], cwd=self.location)
# If develop parameter is set, don't reset/update.
......
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