Commit 3eafc56e authored by Jérome Perrin's avatar Jérome Perrin

gitclone: keep local changes when there is an error during update

parent 9dcf201f
......@@ -403,6 +403,34 @@ In case of uninstall, buildout will keep the repository directory::
Installing git-clone.
destination directory already exists.
If an error occurs during update, the error is catched to prevent buildout
behavior of deleting parts it failed to update. One type of possible error is
fetching from a non existant remote::
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... parts = git-clone
...
... [git-clone]
... recipe = slapos.recipe.build:gitclone
... repository = http://git.erp5.org/repos/slapos.recipe.build.git
... """)
>>> print system(buildout)
Installing git-clone.
...
>>> cd(sample_buildout, 'parts', 'git-clone')
>>> print system('echo kept > local_change')
>>> git remote add broken https://git.erp5.org/repos/nowhere')
...
>>> print system(buildout)
Updating git-clone.
...
Unable to update:
...
>>> print system('cat local_change')
kept
Ignore SSL certificate
~~~~~~~~~~~~~~~~~~~~~~
......
......@@ -242,19 +242,27 @@ class Recipe(object):
If user doesn't develop, reset to remote revision (or branch if revision is
not specified).
"""
# first cleanup pyc files
self.deletePycFiles(self.location)
try:
# first cleanup pyc files
self.deletePycFiles(self.location)
# then update
check_call([self.git_command, 'fetch', '--all'], cwd=self.location)
# then update
check_call([self.git_command, 'fetch', '--all'], cwd=self.location)
# If develop parameter is set, don't reset/update.
# Otherwise, reset --hard
if not self.develop:
if self.revision:
self.gitReset(self.revision)
else:
self.gitReset('@{upstream}')
# If develop parameter is set, don't reset/update.
# Otherwise, reset --hard
if not self.develop:
if self.revision:
self.gitReset(self.revision)
else:
self.gitReset('@{upstream}')
except:
if not self.develop:
raise
# Buildout will remove the installed location and mark the part as not
# installed if an error occurs during update. If we are developping this
# repository we do not want this to happen.
print 'Unable to update:\n%s' % traceback.format_exc()
def uninstall(name, options):
"""Keep the working copy, unless develop is set to false.
......
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