From c754d504cb3825ab00fe82cf40b2352d21818bda Mon Sep 17 00:00:00 2001 From: Lauren Perry Date: Fri, 9 Jan 2015 16:43:40 +0000 Subject: 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 --- firehose/plugin/firehose_plugin.py | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'firehose') 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) -- cgit v1.2.1