summaryrefslogtreecommitdiff
path: root/lorrycontroller/gitano.py
diff options
context:
space:
mode:
Diffstat (limited to 'lorrycontroller/gitano.py')
-rw-r--r--lorrycontroller/gitano.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/lorrycontroller/gitano.py b/lorrycontroller/gitano.py
index 7d9c436..06039b0 100644
--- a/lorrycontroller/gitano.py
+++ b/lorrycontroller/gitano.py
@@ -23,6 +23,7 @@ import cliapp
import requests
import lorrycontroller
+from . import hosts
class GitanoCommandFailure(Exception):
@@ -149,3 +150,42 @@ def new_gitano_command(statedb, trovehost):
trove_info['protocol'],
trove_info['username'],
trove_info['password'])
+
+
+class GitanoDownstream(hosts.DownstreamHost):
+ def __init__(self, app_settings):
+ self._gitano = LocalTroveGitanoCommand()
+
+ def prepare_repo(self, repo_path, metadata):
+ # Create repository on local Trove. If it fails, assume
+ # it failed because the repository already existed, and
+ # ignore the failure (but log message).
+
+ try:
+ self._gitano.create(repo_path)
+ except GitanoCommandFailure as e:
+ logging.debug(
+ 'Ignoring error creating %s on local Trove: %s',
+ repo_path, e)
+ else:
+ logging.info('Created %s on local repo', repo_path)
+
+ try:
+ local_config = self._gitano.get_gitano_config(repo_path)
+ if 'head' in metadata \
+ and metadata['head'] != local_config['project.head']:
+ self._gitano.set_gitano_config(repo_path,
+ 'project.head',
+ metadata['head'])
+ if 'description' in metadata \
+ and metadata['description'] != \
+ local_config['project.description']:
+ self._gitano.set_gitano_config(repo_path,
+ 'project.description',
+ metadata['description'])
+ except GitanoCommandFailure as e:
+ logging.error('ERROR: %s' % str(e))
+ # FIXME: We need a good way to report these errors to the
+ # user. However, we probably don't want to fail the
+ # request, so that's not the way to do this. Needs
+ # thinking.