summaryrefslogtreecommitdiff
path: root/firehose/plugin/firehose_plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'firehose/plugin/firehose_plugin.py')
-rw-r--r--firehose/plugin/firehose_plugin.py48
1 files changed, 35 insertions, 13 deletions
diff --git a/firehose/plugin/firehose_plugin.py b/firehose/plugin/firehose_plugin.py
index ace7bdf..fdd5b20 100644
--- a/firehose/plugin/firehose_plugin.py
+++ b/firehose/plugin/firehose_plugin.py
@@ -156,10 +156,24 @@ class FirehosePlugin(cliapp.Plugin):
def insert_githook(self):
gerrit_username = self.app.settings['gerrit-username']
gerrit_url = self.app.settings['gerrit-url']
- scp_cmd = ('scp', '-p', '-P', '29418', gerrit_username+'@'+gerrit_url+':hooks/commit-msg',
- self.gitpath+'/.git/hooks/commit-msg')
- logging.info('insert_githook: ' + str(scp_cmd))
- os.system(' '.join(scp_cmd))
+ status, output, error = \
+ self.app.runcmd_unchecked(['scp', '-p', '-P', '29418',
+ gerrit_username+'@'+
+ gerrit_url+':hooks/commit-msg',
+ self.gitpath+
+ '/.git/hooks/commit-msg'],
+ cwd=self.gitpath)
+ if status != 0:
+ # Remove the previously recorded hash
+ os.remove(self.sha_filename)
+ if "publickey" in error:
+ raise cliapp.AppException(
+ "Cannot insert githook. "+
+ "Check your ssh public key is registered in gerrit")
+ else:
+ self.app.output.write(error)
+ raise cliapp.AppException(
+ "Woah! unable to insert githook")
def reset_to_tracking(self, root):
logging.info('reset_to_tracking')
@@ -309,14 +323,22 @@ class FirehosePlugin(cliapp.Plugin):
cwd=self.gitpath)
logging.info('commit_and_push: ' + str(code))
if code == 0:
- try:
- # Note: cliapp needs updating such that it supports callbacks
- self.app.runcmd(['git', 'push',
- 'ssh://'+gerrit_username+'@'+gerrit_url+
- ':29418/baserock/baserock/definitions',
- branch_name], cwd=self.gitpath)
- except cliapp.AppException:
+ status, output, error = \
+ self.app.runcmd_unchecked(['git', 'push',
+ 'ssh://'+gerrit_username+
+ '@'+gerrit_url+
+ ':29418/baserock/'+
+ 'baserock/definitions',
+ branch_name], cwd=self.gitpath)
+ if status != 0:
# Remove the previously recorded hash
os.remove(self.sha_filename)
- raise cliapp.AppException(
- "Woah! unable to push changes to gerrit")
+ if "publickey" in error:
+ raise cliapp.AppException(
+ "Could not push to gerrit. "+
+ "Check your ssh public key is "+
+ "registered in gerrit")
+ else:
+ self.app.output.write(error)
+ raise cliapp.AppException(
+ "Woah! unable to push changes to gerrit")