Commit d27df419 authored by Julien Muchembled's avatar Julien Muchembled

Do not upload to cache by default, nor cache working copy

parent 62416e88
Changes
=======
0.12 (Unreleased)
-----------------
* Do not upload to cache by default. 'use-cache' option replaces
'forbid-download-cache' and must be explicitely set in order to use cache.
* Do not cache working copy, which just duplicate `.git` folder.
0.11.6 (2013-02-25)
-------------------
......
......@@ -57,7 +57,8 @@ slapos.recipe.build:gitclone
****************************
Checkout a git repository.
Supports slapos.libnetworkcache if present.
Supports slapos.libnetworkcache if present, and if boolean 'use-cache' option
is true.
Examples
********
......@@ -78,6 +79,7 @@ the recipe will pick up the latest commit on the remote master branch::
... [git-clone]
... recipe = slapos.recipe.build:gitclone
... repository = http://git.erp5.org/repos/slapos.recipe.build.git
... use-cache = true
... """)
This will clone the git repository in `parts/git-clone` directory.
......
from setuptools import setup, find_packages
version = '0.11.6'
version = '0.12-dev'
name = 'slapos.recipe.build'
long_description = open("README.rst").read() + "\n" + \
open("CHANGES.txt").read() + "\n"
......
......@@ -51,7 +51,7 @@ except:
GIT_DEFAULT_REMOTE_NAME = 'origin'
GIT_DEFAULT_BRANCH_NAME = 'master'
TRUE_VALUES = ['y', 'yes', '1', 'true']
TRUE_VALUES = ('y', 'yes', '1', 'true')
GIT_CLONE_ERROR_MESSAGE = 'Impossible to clone repository.'
GIT_CLONE_CACHE_ERROR_MESSAGE = 'Impossible to clone repository and ' \
......@@ -62,7 +62,7 @@ def upload_network_cached(path, name, revision, networkcache_options):
Creates uploads repository to cache.
"""
if not (LIBNETWORKCACHE_ENABLED and networkcache_options.get(
'shacache-cert-file')):
'upload-dir-url')):
return False
try:
print 'Uploading git repository to cache...'
......@@ -132,12 +132,8 @@ class Recipe(object):
self.name = name
self.location = options.get('location')
# Set boolean values
for key in ['develop', 'forbid-download-cache']:
attribute = key.replace('-', '_')
if options.get(key) in TRUE_VALUES:
setattr(self, attribute, True)
else:
setattr(self, attribute, False)
for key in ('develop', 'use-cache'):
setattr(self, key.replace('-', '_'), options.get(key) in TRUE_VALUES)
self.networkcache = buildout.get('networkcache', {})
......@@ -182,18 +178,21 @@ class Recipe(object):
raise UserError("Unknown error while cloning repository.")
if self.revision:
self.gitReset(self.revision)
upload_network_cached(self.location, self.name, self.revision,
self.networkcache)
if self.use_cache:
upload_network_cached(os.path.join(self.location, '.git'),
self.repository, self.revision, self.networkcache)
except CalledProcessError:
print ("Unable to download from git repository. Trying from network "
"cache...")
if os.path.exists(self.location):
shutil.rmtree(self.location)
if self.forbid_download_cache:
if not self.use_cache:
raise UserError(GIT_CLONE_ERROR_MESSAGE)
if not download_network_cached(self.location, self.name, self.revision,
self.networkcache):
os.mkdir(self.location)
if not download_network_cached(os.path.join(self.location, '.git'),
self.repository, self.revision, self.networkcache):
raise UserError(GIT_CLONE_CACHE_ERROR_MESSAGE)
self.gitReset()
return [self.location]
......
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