diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-21 11:44:27 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-21 11:44:27 +0100 |
commit | 35be108f1d6bd01511e132bc06a2ecb1f8da9db0 (patch) | |
tree | d5a69178d915699d71e24f053796f44ca9449ac1 | |
parent | dbc7cee2d8c0c307e8805bde876b30f2fac2eb46 (diff) | |
download | morph-35be108f1d6bd01511e132bc06a2ecb1f8da9db0.tar.gz |
morph foreach: Fix with cliapp < 1.20120630
Use cliapp.Application.runcmd_unchecked() instead of runcmd() to get
the full command output, without requiring AppException.msg (which is
an inferior way to get the output in any case)
-rw-r--r-- | morphlib/plugins/branch_and_merge_plugin.py | 14 | ||||
-rw-r--r-- | tests.branching/foreach-handles-command-failure.stderr | 2 |
2 files changed, 6 insertions, 10 deletions
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py index e2c7ef84..cf54e2e4 100644 --- a/morphlib/plugins/branch_and_merge_plugin.py +++ b/morphlib/plugins/branch_and_merge_plugin.py @@ -982,13 +982,9 @@ class BranchAndMergePlugin(cliapp.Plugin): self.app.output.write('\n') self.app.output.write('%s\n' % repo) - try: - output = self.app.runcmd(args, cwd=d) - except cliapp.AppException as e: - # Don't allow cliapp to swallow the output of the command - # as the body of the exception - output_start = e.msg.find('\n') - self.app.output.write(e.msg[output_start+1:]) - raise cliapp.AppException(e.msg[:output_start]) - + status, output, error = self.app.runcmd_unchecked(args, cwd=d) self.app.output.write(output) + if status != 0: + self.app.output.write(error) + raise cliapp.AppException( + 'Command failed at repo %s: %s' % (repo, ' '.join(args))) diff --git a/tests.branching/foreach-handles-command-failure.stderr b/tests.branching/foreach-handles-command-failure.stderr index d9bc90bf..72942b89 100644 --- a/tests.branching/foreach-handles-command-failure.stderr +++ b/tests.branching/foreach-handles-command-failure.stderr @@ -1 +1 @@ -ERROR: Command failed: git remote update non-existant-remote +ERROR: Command failed at repo baserock:morphs: git remote update non-existant-remote |