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__)
HASH_REGEX = re.compile('[a-fA-F0-9]{40}')
HASH_REGEX = re.compile('^[a-fA-F0-9]{40}$')
def looks_like_hash(sha):

View File

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