gitclone: revision has priority over branch

Both are compatible.
parent 759e932a
...@@ -148,7 +148,7 @@ Specific revision ...@@ -148,7 +148,7 @@ Specific revision
----------------- -----------------
You can specify a specific commit hash or tag using `revision` option. You can specify a specific commit hash or tag using `revision` option.
This option is not compatible with "branch" option:: This option has priority over the "branch" option::
>>> cd(sample_buildout) >>> cd(sample_buildout)
>>> write(sample_buildout, 'buildout.cfg', >>> write(sample_buildout, 'buildout.cfg',
...@@ -222,6 +222,37 @@ extend an existing section specifying a branch):: ...@@ -222,6 +222,37 @@ extend an existing section specifying a branch)::
>>> print system('git branch') >>> print system('git branch')
* master * master
Revision/branch priority
------------------------
If both revision and branch parameters are set, revision parameters is used
and branch parameter is ignored::
>>> 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
... branch = mybranch
... revision = 2566127
... """)
>>> print system(buildout)
Uninstalling git-clone.
Running uninstall recipe.
Installing git-clone.
Warning: "branch" parameter with value "mybranch" is ignored. Checking out to revision 2566127...
Cloning into '/sample-buildout/parts/git-clone'...
HEAD is now at 2566127 ...
>>> cd(sample_buildout, 'parts', 'git-clone')
>>> print system('git branch')
* master
Specific git binary Specific git binary
------------------- -------------------
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
import hashlib import hashlib
import os import os
import shutil import shutil
import sys
import time import time
import traceback import traceback
...@@ -146,9 +147,9 @@ class Recipe(object): ...@@ -146,9 +147,9 @@ class Recipe(object):
if not self.repository: if not self.repository:
raise UserError('repository parameter is mandatory.') raise UserError('repository parameter is mandatory.')
if self.revision and self.branch: if self.revision and self.branch:
# revision and branch options are incompatible # revision option has priority over branch option
raise UserError('revision and branch (other than master) parameters ' self.branch_overrided = self.branch
'are set but are incompatible. Please specify only one of them.') self.branch = None
# Check existence of directory # Check existence of directory
if not os.path.exists(self.location): if not os.path.exists(self.location):
...@@ -180,6 +181,13 @@ class Recipe(object): ...@@ -180,6 +181,13 @@ class Recipe(object):
# If develop is set, assume that this is a valid working copy # If develop is set, assume that this is a valid working copy
return [self.location] return [self.location]
if getattr(self, 'branch_overrided', None):
print('Warning: "branch" parameter with value "%s" is ignored. '
'Checking out to revision %s.' % (
self.branch_overrided, self.revision)
)
sys.stdout.flush()
git_clone_command = [self.git_command, 'clone', git_clone_command = [self.git_command, 'clone',
self.repository, self.repository,
self.location] 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