summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-05-15 07:37:33 +0000
committerGerrit Code Review <review@openstack.org>2015-05-15 07:37:33 +0000
commit5a412bfc497998c4eef381bbf292fc5784dfee90 (patch)
treeafb8304e20630590d5a9d6fb8f6291fb34f6051f
parent2f76173c39d18bdeafd6727ecee92478a6ab9dd6 (diff)
parent0c7321b6d88fa197298326eb094a895b228b0f4b (diff)
downloadzuul-5a412bfc497998c4eef381bbf292fc5784dfee90.tar.gz
Merge "Simplify cloner required parameters"
-rwxr-xr-xzuul/cmd/cloner.py9
-rw-r--r--zuul/lib/cloner.py20
2 files changed, 14 insertions, 15 deletions
diff --git a/zuul/cmd/cloner.py b/zuul/cmd/cloner.py
index d0bb96694..e38892c8f 100755
--- a/zuul/cmd/cloner.py
+++ b/zuul/cmd/cloner.py
@@ -25,10 +25,6 @@ import zuul.lib.cloner
ZUUL_ENV_SUFFIXES = (
'branch',
- 'change',
- 'patchset',
- 'pipeline',
- 'project',
'ref',
'url',
)
@@ -93,10 +89,11 @@ class Cloner(zuul.cmd.ZuulApp):
args = parser.parse_args()
- # Validate ZUUL_* arguments
+ # Validate ZUUL_* arguments. If any ZUUL_* argument is set they
+ # must all be set, otherwise fallback to defaults.
zuul_missing = [zuul_opt for zuul_opt, val in vars(args).items()
if zuul_opt.startswith('zuul') and val is None]
- if zuul_missing:
+ if len(zuul_missing) < len(ZUUL_ENV_SUFFIXES):
parser.error(("Some Zuul parameters are not set:\n\t%s\n"
"Define them either via environment variables or "
"using options above." %
diff --git a/zuul/lib/cloner.py b/zuul/lib/cloner.py
index 39e2e346f..d697648d8 100644
--- a/zuul/lib/cloner.py
+++ b/zuul/lib/cloner.py
@@ -141,22 +141,24 @@ class Cloner(object):
override_zuul_ref = re.sub(self.zuul_branch, indicated_branch,
self.zuul_ref)
- if repo.hasBranch(indicated_branch):
- self.log.debug("upstream repo has branch %s", indicated_branch)
+ if indicated_branch and repo.hasBranch(indicated_branch):
+ self.log.info("upstream repo has branch %s", indicated_branch)
fallback_branch = indicated_branch
else:
- self.log.debug("upstream repo is missing branch %s",
- self.branch)
+ self.log.info("upstream repo is missing branch %s",
+ self.branch)
# FIXME should be origin HEAD branch which might not be 'master'
fallback_branch = 'master'
fallback_zuul_ref = re.sub(self.zuul_branch, fallback_branch,
self.zuul_ref)
- if (self.fetchFromZuul(repo, project, override_zuul_ref)
- or (fallback_zuul_ref != override_zuul_ref and
- self.fetchFromZuul(repo, project, fallback_zuul_ref))
- ):
+ # If we have a non empty zuul_ref to use, use it. Otherwise we fall
+ # back to checking out the branch.
+ if ((override_zuul_ref and
+ self.fetchFromZuul(repo, project, override_zuul_ref)) or
+ (fallback_zuul_ref != override_zuul_ref and
+ self.fetchFromZuul(repo, project, fallback_zuul_ref))):
# Work around a bug in GitPython which can not parse FETCH_HEAD
gitcmd = git.Git(dest)
fetch_head = gitcmd.rev_parse('FETCH_HEAD')
@@ -165,7 +167,7 @@ class Cloner(object):
project, fetch_head)
else:
# Checkout branch
- self.log.debug("Falling back to branch %s", fallback_branch)
+ self.log.info("Falling back to branch %s", fallback_branch)
try:
repo.checkout('remotes/origin/%s' % fallback_branch)
except (ValueError, GitCommandError):