Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d845ec6

Browse files
committed
Merge pull request #375 from vinayinvicible/master
only consider forward diff in changed files
2 parents d2c17ed + b61a0b5 commit d845ec6

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

pre_commit/commands/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _print_user_skipped(hook, write, args):
5151

5252
def get_changed_files(new, old):
5353
return cmd_output(
54-
'git', 'diff', '--name-only', '{0}..{1}'.format(old, new),
54+
'git', 'diff', '--name-only', '{0}...{1}'.format(old, new),
5555
)[1].splitlines()
5656

5757

tests/commands/run_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,10 @@ def test_get_changed_files():
401401
)
402402
assert files == ['CHANGELOG.md', 'setup.py']
403403

404+
# files changed in source but not in origin should not be returned
405+
files = get_changed_files('HEAD~10', 'HEAD')
406+
assert files == []
407+
404408

405409
def test_lots_of_files(mock_out_store_directory, tempdir_factory):
406410
# windows xargs seems to have a bug, here's a regression test for

0 commit comments

Comments
 (0)