1 parent 6654fee commit db97cf3Copy full SHA for db97cf3
2 files changed
pre_commit/git.py
@@ -69,7 +69,11 @@ def get_conflicted_files():
69
70
@memoize_by_cwd
71
def get_staged_files():
72
- return cmd_output('git', 'diff', '--staged', '--name-only')[1].splitlines()
+ return cmd_output(
73
+ 'git', 'diff', '--staged', '--name-only',
74
+ # Everything except for D
75
+ '--diff-filter=ACMRTUXB'
76
+ )[1].splitlines()
77
78
79
tests/git_test.py
@@ -33,6 +33,16 @@ def test_get_root_not_git_dir(tempdir_factory):
33
git.get_root()
34
35
36
+def test_get_staged_files_deleted(tempdir_factory):
37
+ path = git_dir(tempdir_factory)
38
+ with cwd(path):
39
+ open('test', 'a').close()
40
+ cmd_output('git', 'add', 'test')
41
+ cmd_output('git', 'commit', '-m', 'foo', '--allow-empty')
42
+ cmd_output('git', 'rm', '--cached', 'test')
43
+ assert git.get_staged_files() == []
44
+
45
46
def test_is_not_in_merge_conflict(tempdir_factory):
47
path = git_dir(tempdir_factory)
48
with cwd(path):
0 commit comments