From f671375c5ec7600a4f0c35e7a4e8904c25446bdc Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 31 Mar 2015 11:52:28 +0100 Subject: Reintroduce the context manager Without this parsing by cliapp fails Change-Id: Ic02c9e6c4d88358ec8f82d17e6126c860f1c76cb --- firehose/plugin/firehose_plugin.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/firehose/plugin/firehose_plugin.py b/firehose/plugin/firehose_plugin.py index 5e9a55b..33381bf 100644 --- a/firehose/plugin/firehose_plugin.py +++ b/firehose/plugin/firehose_plugin.py @@ -26,6 +26,16 @@ 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@merge.bot"]) + 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): @@ -44,7 +54,7 @@ class FirehosePlugin(cliapp.Plugin): for fname in args: with open(fname, "r") as fh: confs.append(FirehoseConfig(fname, fh)) - + # Ensure all incoming configurations are based on, and landing in, the # same repository. This is because we're only supporting an aggregated # integration mode for now. @@ -56,7 +66,7 @@ class FirehosePlugin(cliapp.Plugin): if len(set(c.landing_myref for c in confs)) > 1: raise cliapp.AppException("Not all firehoses have the same landing myref") - + # Ensure that all incoming configurations have unique things they are # integrating into. Note: this allows for the same upstream to be # tracked in multiple configs, providing they are all targetting a @@ -181,7 +191,7 @@ class FirehosePlugin(cliapp.Plugin): else: raise FirehoseConfigError(conf, "Unknown value: %s" % conf.tracking_mode, ["tracking", "mode"]) - + def rewrite_ref(self, conf, ref): if conf.tracking_mode == 'refs': for transform in conf.tracking_transforms: @@ -237,7 +247,7 @@ class FirehosePlugin(cliapp.Plugin): self.loader.save_to_file( self.sb.get_filename(morph.repo_url, morph.filename), morph) morph.dirty = False - + return True def commit_and_push(self, name): @@ -251,4 +261,3 @@ class FirehosePlugin(cliapp.Plugin): if code == 0: self.app.runcmd(['git', 'push', 'ssh://'+gerrit_username+'@'+gerrit_url+ ':29418/baserock/baserock/definitions', branch_name], cwd=self.gitpath) - -- cgit v1.2.1