mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 11:36:54 +00:00
Merge 321e2602eb into bf8369c862
This commit is contained in:
commit
12b06ba136
2 changed files with 17 additions and 5 deletions
|
|
@ -8,7 +8,7 @@ import sys
|
|||
|
||||
|
||||
GITHUB_NON_PERMALINK = re.compile(
|
||||
b'https://github.com/[^/]+/[^/]+/blob/master/[^# ]+#L\d+',
|
||||
b'https?://(www\.)?github.com/[^/]+/[^/]+/blob/master/[^# ]+#',
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
from __future__ import absolute_import
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import pytest
|
||||
|
||||
from pre_commit_hooks.check_vcs_permalinks import main
|
||||
|
||||
|
||||
|
|
@ -20,17 +22,27 @@ def test_passing(tmpdir):
|
|||
assert not main((f.strpath,))
|
||||
|
||||
|
||||
def test_failing(tmpdir, capsys):
|
||||
@pytest.mark.parametrize(
|
||||
'contents',
|
||||
(
|
||||
'http://github.com/asottile/test/blob/master/foo#L1',
|
||||
'http://www.github.com/asottile/test/blob/master/foo#L1',
|
||||
'https://github.com/asottile/test/blob/master/foo#L1',
|
||||
'https://www.github.com/asottile/test/blob/master/foo#L1',
|
||||
'https://www.github.com/asottile/test/blob/master/foo#my-anchor',
|
||||
),
|
||||
)
|
||||
def test_failing(contents, tmpdir, capsys):
|
||||
with tmpdir.as_cwd():
|
||||
tmpdir.join('f.txt').write_binary(
|
||||
b'https://github.com/asottile/test/blob/master/foo#L1\n',
|
||||
'{}\n'.format(contents).encode('utf-8'),
|
||||
)
|
||||
|
||||
assert main(('f.txt',))
|
||||
out, _ = capsys.readouterr()
|
||||
assert out == (
|
||||
'f.txt:1:https://github.com/asottile/test/blob/master/foo#L1\n'
|
||||
'f.txt:1:{}\n'
|
||||
'\n'
|
||||
'Non-permanent github link detected.\n'
|
||||
'On any page on github press [y] to load a permalink.\n'
|
||||
'On any page on github press [y] to load a permalink.\n'.format(contents)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue