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

Merge pull request #6639 from sbidoul/imp_looks_like_hash-sbi

Be stricter in identiying git commit hashes
This commit is contained in:
Chris Jerdonek 2019-06-23 08:49:11 -07:00 committed by GitHub
commit 36430e2a43
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 1 deletions

View file

@ -0,0 +1 @@
Be stricter in identifying git commit hashes.

View file

@ -23,7 +23,7 @@ urlunsplit = urllib_parse.urlunsplit
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
HASH_REGEX = re.compile('[a-fA-F0-9]{40}') HASH_REGEX = re.compile('^[a-fA-F0-9]{40}$')
def looks_like_hash(sha): def looks_like_hash(sha):

View file

@ -105,6 +105,7 @@ def test_looks_like_hash():
assert looks_like_hash(18 * 'a' + '0123456789abcdefABCDEF') assert looks_like_hash(18 * 'a' + '0123456789abcdefABCDEF')
assert not looks_like_hash(40 * 'g') assert not looks_like_hash(40 * 'g')
assert not looks_like_hash(39 * 'a') assert not looks_like_hash(39 * 'a')
assert not looks_like_hash(41 * 'a')
@pytest.mark.parametrize('vcs_cls, remote_url, expected', [ @pytest.mark.parametrize('vcs_cls, remote_url, expected', [