mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Sync: Refactor netrc parsing
Don't emit a message when the netrc file doesn't exist or couldn't be opened. Instead of trying to unpack the result of info.authenticators() and catching the resulting TypeError when it's None, first store it to a local and only unpack it if it has a value. Also remove an unused import. Change-Id: I5c404d91e48c261c1ab850c3e5f040c4f4c235cb
This commit is contained in:
parent
f4599a2a3d
commit
ba7bc738c1
@ -65,7 +65,7 @@ except ImportError:
|
|||||||
multiprocessing = None
|
multiprocessing = None
|
||||||
|
|
||||||
from git_command import GIT, git_require
|
from git_command import GIT, git_require
|
||||||
from git_config import GetSchemeFromUrl, GetUrlCookieFile
|
from git_config import GetUrlCookieFile
|
||||||
from git_refs import R_HEADS, HEAD
|
from git_refs import R_HEADS, HEAD
|
||||||
import gitc_utils
|
import gitc_utils
|
||||||
from project import Project
|
from project import Project
|
||||||
@ -586,17 +586,16 @@ later is required to fix a server side protocol bug.
|
|||||||
try:
|
try:
|
||||||
info = netrc.netrc()
|
info = netrc.netrc()
|
||||||
except IOError:
|
except IOError:
|
||||||
print('.netrc file does not exist or could not be opened',
|
# .netrc file does not exist or could not be opened
|
||||||
file=sys.stderr)
|
pass
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
parse_result = urllib.parse.urlparse(manifest_server)
|
parse_result = urllib.parse.urlparse(manifest_server)
|
||||||
if parse_result.hostname:
|
if parse_result.hostname:
|
||||||
username, _account, password = \
|
auth = info.authenticators(parse_result.hostname)
|
||||||
info.authenticators(parse_result.hostname)
|
if auth:
|
||||||
except TypeError:
|
username, _account, password = auth
|
||||||
# TypeError is raised when the given hostname is not present
|
else:
|
||||||
# in the .netrc file.
|
|
||||||
print('No credentials found for %s in .netrc'
|
print('No credentials found for %s in .netrc'
|
||||||
% parse_result.hostname, file=sys.stderr)
|
% parse_result.hostname, file=sys.stderr)
|
||||||
except netrc.NetrcParseError as e:
|
except netrc.NetrcParseError as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user