Skip to content

Commit

Permalink
Address review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjerdonek committed Dec 21, 2018
1 parent 1e903ea commit 929c958
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/pip/_internal/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ def call_subprocess(
show_stdout=True, # type: bool
cwd=None, # type: Optional[str]
on_returncode='raise', # type: str
returncodes=None, # type: Optional[Iterable[int]]
extra_ok_returncodes=None, # type: Optional[Iterable[int]]
command_desc=None, # type: Optional[str]
extra_environ=None, # type: Optional[Mapping[str, Any]]
unset_environ=None, # type: Optional[Iterable[str]]
Expand All @@ -662,13 +662,13 @@ def call_subprocess(
# type: (...) -> Optional[Text]
"""
Args:
returncodes: an iterable of integer return codes that are acceptable,
in addition to 0. Defaults to None, which means [].
extra_ok_returncodes: an iterable of integer return codes that are
acceptable, in addition to 0. Defaults to None, which means [].
unset_environ: an iterable of environment variable names to unset
prior to calling subprocess.Popen().
"""
if returncodes is None:
returncodes = []
if extra_ok_returncodes is None:
extra_ok_returncodes = []
if unset_environ is None:
unset_environ = []
# This function's handling of subprocess output is confusing and I
Expand Down Expand Up @@ -745,7 +745,7 @@ def call_subprocess(
spinner.finish("error")
else:
spinner.finish("done")
if proc.returncode and proc.returncode not in returncodes:
if proc.returncode and proc.returncode not in extra_ok_returncodes:
if on_returncode == 'raise':
if (logger.getEffectiveLevel() > std_logging.DEBUG and
not show_stdout):
Expand Down
4 changes: 2 additions & 2 deletions src/pip/_internal/vcs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def run_command(
show_stdout=True, # type: bool
cwd=None, # type: Optional[str]
on_returncode='raise', # type: str
returncodes=None, # type: Optional[Iterable[int]]
extra_ok_returncodes=None, # type: Optional[Iterable[int]]
command_desc=None, # type: Optional[str]
extra_environ=None, # type: Optional[Mapping[str, Any]]
spinner=None # type: Optional[SpinnerInterface]
Expand All @@ -482,7 +482,7 @@ def run_command(
try:
return call_subprocess(cmd, show_stdout, cwd,
on_returncode=on_returncode,
returncodes=returncodes,
extra_ok_returncodes=extra_ok_returncodes,
command_desc=command_desc,
extra_environ=extra_environ,
unset_environ=self.unset_environ,
Expand Down
8 changes: 5 additions & 3 deletions src/pip/_internal/vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ def get_current_branch(self, location):
Return the current branch, or None if HEAD isn't at a branch
(e.g. detached HEAD).
"""
# The -q causes the command to exit with status code 1 instead of
# 128 if "HEAD" is not a symbolic ref but a detached HEAD.
# git-symbolic-ref exits with empty stdout if "HEAD" is a detached
# HEAD rather than a symbolic ref. In addition, the -q causes the
# command to exit with status code 1 instead of 128 in this case
# and to suppress the message to stderr.
args = ['symbolic-ref', '-q', 'HEAD']
output = self.run_command(
args, returncodes=(1, ), show_stdout=False, cwd=location,
args, extra_ok_returncodes=(1, ), show_stdout=False, cwd=location,
)
ref = output.strip()

Expand Down

0 comments on commit 929c958

Please sign in to comment.