summaryrefslogtreecommitdiff
path: root/firehose
diff options
context:
space:
mode:
authorLauren Perry <lauren.perry@codethink.co.uk>2015-01-09 16:43:40 +0000
committerLauren Perry <lauren.perry@codethink.co.uk>2015-01-09 16:43:40 +0000
commitc754d504cb3825ab00fe82cf40b2352d21818bda (patch)
treee734e79a002f9e73856b0efb43d1ce01ee2a0de7 /firehose
parent63b5ad5b246df02c5cae2f31075283b385c582c4 (diff)
downloadfirehose-c754d504cb3825ab00fe82cf40b2352d21818bda.tar.gz
Obtain Gerrit user identity and Gerrit URL from firehose.morph during
deployment, rather than hardcoding values, and remove changing of git identity, which is now also set in firehose.morph
Diffstat (limited to 'firehose')
-rw-r--r--firehose/plugin/firehose_plugin.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/firehose/plugin/firehose_plugin.py b/firehose/plugin/firehose_plugin.py
index 66116bf..5e9a55b 100644
--- a/firehose/plugin/firehose_plugin.py
+++ b/firehose/plugin/firehose_plugin.py
@@ -26,23 +26,13 @@ import morphlib
from debian.debian_support import Version
@contextmanager
-def firehose_git(app):
- try:
- username = (app.runcmd_unchecked(["git", "config", "--global", "user.name"]))[1].strip()
- email = (app.runcmd_unchecked(["git", "config", "--global", "user.email"]))[1].strip()
- app.runcmd(["git", "config", "--global", "user.name", "Firehose merge bot"])
- app.runcmd(["git", "config", "--global", "user.email", "firehose@firehose.baserock.org"])
- yield ()
- finally:
- app.runcmd(["git", "config", "--global", "user.name", username])
- app.runcmd(["git", "config", "--global", "user.email", email])
-
-
class FirehosePlugin(cliapp.Plugin):
def enable(self):
self.app.add_subcommand('firehose', self.firehose_cmd,
arg_synopsis='some-firehose.yaml...')
+ self.app.settings(['gerrit_username'], 'gerrit_username')
+ self.app.settings(['gerrit_url'], 'gerrit_url')
def disable(self):
pass
@@ -120,7 +110,9 @@ class FirehosePlugin(cliapp.Plugin):
log.write('{\"sha\":\"'+sha+'\"}')
def insert_githook(self):
- scp_cmd = ('scp', '-p', '-P', '29418', 'firehose@testgerrit.baserock.org:hooks/commit-msg',
+ 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')
os.system(' '.join(scp_cmd))
@@ -249,12 +241,14 @@ class FirehosePlugin(cliapp.Plugin):
return True
def commit_and_push(self, name):
+ gerrit_username = self.app.settings['gerrit_username']
+ gerrit_url = self.app.settings['gerrit_url']
commit_msg = 'Update to '+name+' ref in definitions.git'
branch_name = 'HEAD:refs/for/master/firehose/'+name
(code, out, err) = self.app.runcmd_unchecked(
['git', 'commit', '-a', '-m', commit_msg],
cwd=self.gitpath)
if code == 0:
- self.app.runcmd(['git', 'push', 'ssh://firehose@testgerrit.baserock.org:29418/baserock/baserock/definitions',
- branch_name], cwd=self.gitpath)
+ self.app.runcmd(['git', 'push', 'ssh://'+gerrit_username+'@'+gerrit_url+
+ ':29418/baserock/baserock/definitions', branch_name], cwd=self.gitpath)