gitclone: empty parameter equals no parameter.

It allows to easily extend an existing section
parent 1847206c
......@@ -188,6 +188,39 @@ When updating, it will do a "git fetch; git reset revision"::
Updating git-clone.
Fetching origin
HEAD is now at ...
Empty revision/branch
---------------------
Specifying an empty revision or an empty branch will make buildout
ignore those values as if it was not present at all (allowing to easily
extend an existing section specifying a branch)::
>>> cd(sample_buildout)
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... parts = git-clone
...
... [git-clone-with-branch]
... recipe = slapos.recipe.build:gitclone
... repository = http://git.erp5.org/repos/slapos.recipe.build.git
... revision = 2566127
...
... [git-clone]
... <= git-clone-with-branch
... revision =
... branch = master
... """)
>>> print system(buildout)
Uninstalling git-clone.
Running uninstall recipe.
Installing git-clone.
Cloning into '/sample-buildout/parts/git-clone'...
>>> cd(sample_buildout, 'parts', 'git-clone')
>>> print system('git branch')
* master
Specific git binary
-------------------
......
......@@ -126,12 +126,16 @@ class Recipe(object):
def __init__(self, buildout, name, options):
options.setdefault('location',
os.path.join(buildout['buildout']['parts-directory'], name))
self.repository = options.get('repository')
self.branch = options.get('branch')
self.revision = options.get('revision')
self.git_command = options.get('git-executable', 'git')
self.name = name
self.location = options.get('location')
for option in ('branch', 'revision', 'location', 'repository'):
value = options.get(option, '').strip()
if value == '':
setattr(self, option, None)
else:
setattr(self, option, value)
self.git_command = options.get('git-executable', '')
if self.git_command == '':
self.git_command = 'git'
# Set boolean values
for key in ('develop', 'use-cache', 'ignore-ssl-certificate'):
setattr(self, key.replace('-', '_'), options.get(key) in TRUE_VALUES)
......
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