diff options
author | Owen W. Taylor <otaylor@fishsoup.net> | 2009-08-30 21:01:31 -0400 |
---|---|---|
committer | Owen W. Taylor <otaylor@fishsoup.net> | 2009-08-30 21:01:31 -0400 |
commit | aaa94d05aabd81bee0874f4b596b71fded3033ad (patch) | |
tree | 54afb30ed692581ad2e62dc7f44ae1290271b02d | |
parent | febe0d49661b7af96dd93e8cb9774be3d92bb014 (diff) |
Allow capturing stderr from a run git command
If _return_error=True is added to git.<command_name>() then a
tuple of captured output from stderr, stdout is returned. We'll
need this to parse the output of 'git push' which goes to stderr.
-rwxr-xr-x | git-bz | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -242,6 +242,7 @@ global_options = None # _quiet: Discard all output even if an error occurs # _interactive: Don't capture stdout and stderr # _input=<str>: Feed <str> to stdinin of the command +# _return_error: Return tuple of captured (stdout,stderr) # def git_run(command, *args, **kwargs): to_run = ['git', command.replace("_", "-")] @@ -250,11 +251,14 @@ def git_run(command, *args, **kwargs): quiet = False input = None interactive = False + return_stderr = False for (k,v) in kwargs.iteritems(): if k == '_quiet': quiet = True elif k == '_interactive': interactive = True + elif k == '_return_stderr': + return_stderr = True elif k == '_input': input = v elif v is True: @@ -280,6 +284,8 @@ def git_run(command, *args, **kwargs): if interactive: return None + elif return_stderr: + return output.strip(), error.strip() else: return output.strip() |