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.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)