1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Address review comments.

This commit is contained in:
Chris Jerdonek 2017-09-01 18:25:28 -07:00
parent dd58b1427f
commit 4ed70c03d9

View file

@ -103,14 +103,19 @@ class Git(VersionControl):
show_stdout=False, on_returncode='ignore') show_stdout=False, on_returncode='ignore')
refs = {} refs = {}
for line in output.strip().splitlines(): for line in output.strip().splitlines():
sha, ref = line.split(None, 1) try:
sha, ref = line.split()
except ValueError:
# Include the offending line to simplify troubleshooting if
# this error ever occurs.
raise ValueError('unexpected show-ref line: {!r}'.format(line))
refs[ref] = sha refs[ref] = sha
sha = refs.get('refs/remotes/origin/{}'.format(rev)) branch_ref = 'refs/remotes/origin/{}'.format(rev)
if sha is not None: tag_ref = 'refs/tags/{}'.format(rev)
return sha
return refs.get('refs/tags/{}'.format(rev)) return refs.get(branch_ref) or refs.get(tag_ref)
def check_rev_options(self, dest, rev_options): def check_rev_options(self, dest, rev_options):
"""Check the revision options before checkout. """Check the revision options before checkout.