Commit e5391695 authored by Kirill Smelkov's avatar Kirill Smelkov

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 12838d5e
......@@ -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,8 +244,14 @@ class Recipe(object):
# first cleanup pyc files
self.deletePycFiles(self.location)
# then update
check_call([self.git_command, 'fetch', '--all'], cwd=self.location)
# 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.
# Otherwise, reset --hard
......
  • @kazuhiko, @jerome, can we please make a new slapos.recipe.build release to pick up this patch in our slapos stack?

    Thanks beforehand, Kirill

  • it looks fine for me. i wait for @jerome response and then release the new version.

    Edited by Kazuhiko Shiozaki
  • Looks fine to me as well 👍

  • @jerome, @kazuhiko, thanks. Looking forward for new release.

  • Released. Since I forgot to push my changes for 0.22, I pushed force to the repository, sorry...

  • @kazuhiko, thanks for doing the release. Please be careful next time - we try to avoid rewriting history on official branches of main repositories.

    Ok to apply next patch to slapos.git?

    From: Kirill Smelkov <kirr@nexedi.com>
    Date: Thu, 22 Oct 2015 16:18:22 +0300
    Subject: [PATCH] stack/slapos: v↑ slapos.recipe.build
    
    ---
     stack/slapos.cfg | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    diff --git a/stack/slapos.cfg b/stack/slapos.cfg
    index e24fd97..f6a05a1 100644
    --- a/stack/slapos.cfg
    +++ b/stack/slapos.cfg
    @@ -139,7 +139,7 @@ slapos.cookbook = 1.0.9
     slapos.core = 1.3.12
     slapos.extension.strip = 0.1
     slapos.libnetworkcache = 0.14.5
    -slapos.recipe.build = 0.21
    +slapos.recipe.build = 0.23
     slapos.recipe.cmmi = 0.2
     stevedore = 1.9.0
     unicodecsv = 0.14.1
    -- 
    2.6.2.350.g3b31934
  • sure 😃

  • Thanks, done: slapos@873517f7.

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