Add some doctests for gitclone recipe

parent f869cb59
......@@ -252,6 +252,8 @@ Notes
Currently, the modules will be installed in site-perl directory. Location of this
directory changes depending on the perl installation.
****************************
slapos.recipe.build:gitclone
****************************
......@@ -262,20 +264,36 @@ Supports slapos.libnetworkcache if present.
Examples
********
Those examples use slapos.recipe.build repository as an example.
Simple clone
------------
Only `url` parameter is required. For each buildout run,
Only `repository` parameter is required. For each buildout run,
the recipe will pick up the latest commit on the remote master branch::
[buildout]
parts = git-clone
[git-clone]
recipe = slapos.recipe.build:gitclone
repository = http://example.net/example.git/
>>> 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
... """)
This will clone the git repository in `parts/git-clone` directory.
Then let's run the buildout::
>>> print system(buildout)
Installing git-clone.
Cloning into '/sample-buildout/parts/git-clone'...
Let's take a look at the buildout parts directory now::
>>> ls(sample_buildout, 'parts')
d buildout
d git-clone
Specific branch
---------------
......@@ -283,13 +301,35 @@ Specific branch
You can specify a specific branch using `branch` option. For each
run it will take the latest commit on this remote branch::
[buildout]
parts = git-clone
>>> 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
... branch = build
... """)
[git-clone]
recipe = slapos.recipe.build:gitclone
repository = http://example.net/example.git/
branch = testing
Then let's run the buildout::
>>> print system(buildout)
Uninstalling git-clone.
Installing git-clone.
Cloning into '/sample-buildout/parts/git-clone'...
Let's take a look at the buildout parts directory now::
>>> ls(sample_buildout, 'parts')
d buildout
d git-clone
And let's see that current branch is "build"::
>>> import subprocess
>>> cd('parts', 'git-clone')
>>> subprocess.check_output(['git', 'branch'])
'* build\n'
Specific revision
-----------------
......@@ -297,13 +337,37 @@ Specific revision
You can specify a specific commit hash or tag using `revision` option.
This option is not compatible with "branch" option::
[buildout]
parts = git-clone
>>> cd(sample_buildout)
>>> 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
... revision = 2566127
... """)
[git-clone]
recipe = slapos.recipe.build:gitclone
repository = http://example.net/example.git/
revision = 0123456789abcdef
Then let's run the buildout::
>>> print system(buildout)
Uninstalling git-clone.
Installing git-clone.
Cloning into '/sample-buildout/parts/git-clone'...
Let's take a look at the buildout parts directory now::
>>> ls(sample_buildout, 'parts')
d buildout
d git-clone
And let's see that current branch is "gitclone"::
>>> import subprocess
>>> cd(sample_buildout, 'parts', 'git-clone')
>>> subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'])
'2566127\n'
Specific git binary
-------------------
......
......@@ -26,6 +26,11 @@ setup(name=name,
'zc.buildout', # plays with buildout
'slapos.libnetworkcache>=0.13.1', # Uses helper new in this version
],
extras_require={
'test' : ['zope.testing'],
},
tests_require = ['zope.testing'],
test_suite = '%s.tests.test_suite' % name,
zip_safe=True,
entry_points={
'zc.buildout': [
......
......@@ -57,6 +57,9 @@ 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')):
return False
try:
print 'Uploading git repository to cache...'
metadata_dict = {
......@@ -126,8 +129,7 @@ class Recipe(object):
if options.get('develop') in TRUE_VALUES:
self.develop = True
# XXX clean
self.networkcache = buildout.get('networkcache')
self.networkcache = buildout.get('networkcache', {})
# Check if input is correct
if not self.repository:
......
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