|
| 1 | +from pre_commit import git |
1 | 2 | from pre_commit.meta_hooks import check_useless_excludes |
| 3 | +from pre_commit.util import cmd_output |
2 | 4 | from testing.fixtures import add_config_to_repo |
| 5 | +from testing.fixtures import make_config_from_repo |
| 6 | +from testing.fixtures import make_repo |
| 7 | +from testing.util import xfailif_windows |
3 | 8 |
|
4 | 9 |
|
5 | 10 | def test_useless_exclude_global(capsys, in_git_dir): |
@@ -113,3 +118,20 @@ def test_valid_exclude(capsys, in_git_dir): |
113 | 118 |
|
114 | 119 | out, _ = capsys.readouterr() |
115 | 120 | assert out == '' |
| 121 | + |
| 122 | + |
| 123 | +@xfailif_windows # pragma: win32 no cover |
| 124 | +def test_useless_excludes_broken_symlink(capsys, in_git_dir, tempdir_factory): |
| 125 | + path = make_repo(tempdir_factory, 'script_hooks_repo') |
| 126 | + config = make_config_from_repo(path) |
| 127 | + config['hooks'][0]['exclude'] = 'broken-symlink' |
| 128 | + add_config_to_repo(in_git_dir.strpath, config) |
| 129 | + |
| 130 | + in_git_dir.join('broken-symlink').mksymlinkto('DNE') |
| 131 | + cmd_output('git', 'add', 'broken-symlink') |
| 132 | + git.commit() |
| 133 | + |
| 134 | + assert check_useless_excludes.main(('.pre-commit-config.yaml',)) == 0 |
| 135 | + |
| 136 | + out, _ = capsys.readouterr() |
| 137 | + assert out == '' |
0 commit comments