11
11
from pip ._vendor .six .moves .urllib import parse as urllib_parse
12
12
from pip ._vendor .six .moves .urllib import request as urllib_request
13
13
14
- from pip ._internal .exceptions import BadCommand , InstallationError
14
+ from pip ._internal .exceptions import BadCommand , SubProcessError
15
15
from pip ._internal .utils .misc import display_path , hide_url
16
16
from pip ._internal .utils .subprocess import make_command
17
17
from pip ._internal .utils .temp_dir import TempDirectory
@@ -78,7 +78,7 @@ def is_immutable_rev_checkout(self, url, dest):
78
78
79
79
def get_git_version (self ):
80
80
VERSION_PFX = 'git version '
81
- version = self .run_command (['version' ], show_stdout = False )
81
+ version = self .run_command (['version' ])
82
82
if version .startswith (VERSION_PFX ):
83
83
version = version [len (VERSION_PFX ):].split ()[0 ]
84
84
else :
@@ -101,7 +101,7 @@ def get_current_branch(cls, location):
101
101
# and to suppress the message to stderr.
102
102
args = ['symbolic-ref' , '-q' , 'HEAD' ]
103
103
output = cls .run_command (
104
- args , extra_ok_returncodes = (1 , ), show_stdout = False , cwd = location ,
104
+ args , extra_ok_returncodes = (1 , ), cwd = location ,
105
105
)
106
106
ref = output .strip ()
107
107
@@ -120,7 +120,7 @@ def export(self, location, url):
120
120
self .unpack (temp_dir .path , url = url )
121
121
self .run_command (
122
122
['checkout-index' , '-a' , '-f' , '--prefix' , location ],
123
- show_stdout = False , cwd = temp_dir .path
123
+ cwd = temp_dir .path
124
124
)
125
125
126
126
@classmethod
@@ -134,8 +134,13 @@ def get_revision_sha(cls, dest, rev):
134
134
rev: the revision name.
135
135
"""
136
136
# Pass rev to pre-filter the list.
137
- output = cls .run_command (['show-ref' , rev ], cwd = dest ,
138
- show_stdout = False , on_returncode = 'ignore' )
137
+
138
+ output = ''
139
+ try :
140
+ output = cls .run_command (['show-ref' , rev ], cwd = dest )
141
+ except SubProcessError :
142
+ pass
143
+
139
144
refs = {}
140
145
for line in output .strip ().splitlines ():
141
146
try :
@@ -286,7 +291,7 @@ def get_remote_url(cls, location):
286
291
# exits with return code 1 if there are no matching lines.
287
292
stdout = cls .run_command (
288
293
['config' , '--get-regexp' , r'remote\..*\.url' ],
289
- extra_ok_returncodes = (1 , ), show_stdout = False , cwd = location ,
294
+ extra_ok_returncodes = (1 , ), cwd = location ,
290
295
)
291
296
remotes = stdout .splitlines ()
292
297
try :
@@ -306,7 +311,7 @@ def get_revision(cls, location, rev=None):
306
311
if rev is None :
307
312
rev = 'HEAD'
308
313
current_rev = cls .run_command (
309
- ['rev-parse' , rev ], show_stdout = False , cwd = location ,
314
+ ['rev-parse' , rev ], cwd = location ,
310
315
)
311
316
return current_rev .strip ()
312
317
@@ -319,7 +324,7 @@ def get_subdirectory(cls, location):
319
324
# find the repo root
320
325
git_dir = cls .run_command (
321
326
['rev-parse' , '--git-dir' ],
322
- show_stdout = False , cwd = location ).strip ()
327
+ cwd = location ).strip ()
323
328
if not os .path .isabs (git_dir ):
324
329
git_dir = os .path .join (location , git_dir )
325
330
repo_root = os .path .abspath (os .path .join (git_dir , '..' ))
@@ -378,15 +383,13 @@ def get_repository_root(cls, location):
378
383
r = cls .run_command (
379
384
['rev-parse' , '--show-toplevel' ],
380
385
cwd = location ,
381
- show_stdout = False ,
382
- on_returncode = 'raise' ,
383
386
log_failed_cmd = False ,
384
387
)
385
388
except BadCommand :
386
389
logger .debug ("could not determine if %s is under git control "
387
390
"because git is not available" , location )
388
391
return None
389
- except InstallationError :
392
+ except SubProcessError :
390
393
return None
391
394
return os .path .normpath (r .rstrip ('\r \n ' ))
392
395
0 commit comments