summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lorrycontroller/gerrit.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/lorrycontroller/gerrit.py b/lorrycontroller/gerrit.py
index 475ef08..629d00d 100644
--- a/lorrycontroller/gerrit.py
+++ b/lorrycontroller/gerrit.py
@@ -74,20 +74,24 @@ class GerritDownstream(hosts.DownstreamHost):
if self._has_project(name):
logging.info('Project %s exists in local Gerrit already.',
name)
- else:
- self._ssh_command.run(['gerrit', 'create-project',
- '-p', self._parent_project,
- name])
- logging.info('Created %s project in local Gerrit.', name)
- # We can only set this metadata if we're the owner of the
- # repository. For now, ignore failures.
- try:
+ # We can only set this metadata if we're the owner of the
+ # repository. For now, ignore failures.
+ try:
+ if 'head' in metadata:
+ self._ssh_command.run(['gerrit', 'set-head', name,
+ '--new-head', metadata['head']])
+ if 'description' in metadata:
+ self._ssh_command.run(['gerrit', 'set-project', name,
+ '-d', metadata['description']])
+ except cliapp.AppException:
+ pass
+ else:
+ create_args = ['gerrit', 'create-project', name,
+ '-p', self._parent_project]
if 'head' in metadata:
- self._ssh_command.run(['gerrit', 'set-head', name,
- '--new-head', metadata['head']])
+ create_args.extend(['-b', metadata['head']])
if 'description' in metadata:
- self._ssh_command.run(['gerrit', 'set-project', name,
- '-d', metadata['description']])
- except cliapp.AppException:
- pass
+ create_args.extend(['-d', metadata['description']])
+ self._ssh_command.run(create_args)
+ logging.info('Created %s project in local Gerrit.', name)