Fix for git pull --tags
when using git 1.7.1
- Added `ignore_errors` option to `Executable.__call__` - Can avoid raising errors on *specific* error return values.
This commit is contained in:
parent
0b5ca25358
commit
cfb883646f
@ -437,7 +437,10 @@ def fetch(self):
|
||||
# cloning. Later git versions can do this with clone
|
||||
# --branch, but older ones fail.
|
||||
if self.tag and self.git_version < ver('1.8.5.2'):
|
||||
self.git('pull', '--tags')
|
||||
# pull --tags returns a "special" error code of 1 in
|
||||
# older versions that we have to ignore.
|
||||
# see: https://github.com/git/git/commit/19d122b
|
||||
self.git('pull', '--tags', ignore_errors=1)
|
||||
self.git('checkout', self.tag)
|
||||
|
||||
|
||||
|
@ -57,8 +57,13 @@ def __call__(self, *args, **kwargs):
|
||||
"""Run the executable with subprocess.check_output, return output."""
|
||||
return_output = kwargs.get("return_output", False)
|
||||
fail_on_error = kwargs.get("fail_on_error", True)
|
||||
ignore_errors = kwargs.get("ignore_errors", ())
|
||||
error = kwargs.get("error", sys.stderr)
|
||||
|
||||
# if they just want to ignore one error code, make it a tuple.
|
||||
if isinstance(ignore_errors, int):
|
||||
ignore_errors = (ignore_errors,)
|
||||
|
||||
quoted_args = [arg for arg in args if re.search(r'^"|^\'|"$|\'$', arg)]
|
||||
if quoted_args:
|
||||
tty.warn("Quotes in command arguments can confuse scripts like configure.",
|
||||
@ -85,7 +90,8 @@ def __call__(self, *args, **kwargs):
|
||||
out, err = proc.communicate()
|
||||
self.returncode = proc.returncode
|
||||
|
||||
if fail_on_error and proc.returncode != 0:
|
||||
rc = proc.returncode
|
||||
if fail_on_error and rc != 0 and (rc not in ignore_errors):
|
||||
raise ProcessError("Command exited with status %d:"
|
||||
% proc.returncode, cmd_line)
|
||||
if return_output:
|
||||
|
Loading…
Reference in New Issue
Block a user