mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Fix staged-files-only for git add --intent-to-add files
This commit is contained in:
parent
2941a1142b
commit
e60579d9f3
4 changed files with 71 additions and 5 deletions
|
|
@ -155,3 +155,21 @@ def test_get_conflicted_files_non_ascii(in_merge_conflict):
|
|||
cmd_output('git', 'add', '.')
|
||||
ret = git.get_conflicted_files()
|
||||
assert ret == {'conflict_file', 'интервью'}
|
||||
|
||||
|
||||
def test_intent_to_add(in_git_dir):
|
||||
in_git_dir.join('a').ensure()
|
||||
cmd_output('git', 'add', '--intent-to-add', 'a')
|
||||
|
||||
assert git.intent_to_add_files() == ['a']
|
||||
|
||||
|
||||
def test_status_output_with_rename(in_git_dir):
|
||||
in_git_dir.join('a').write('1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n')
|
||||
cmd_output('git', 'add', 'a')
|
||||
git_commit()
|
||||
cmd_output('git', 'mv', 'a', 'b')
|
||||
in_git_dir.join('c').ensure()
|
||||
cmd_output('git', 'add', '--intent-to-add', 'c')
|
||||
|
||||
assert git.intent_to_add_files() == ['c']
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import shutil
|
|||
|
||||
import pytest
|
||||
|
||||
from pre_commit import git
|
||||
from pre_commit.staged_files_only import staged_files_only
|
||||
from pre_commit.util import cmd_output
|
||||
from testing.auto_namedtuple import auto_namedtuple
|
||||
|
|
@ -339,3 +340,14 @@ def test_autocrlf_commited_crlf(in_git_dir, patch_dir):
|
|||
|
||||
with staged_files_only(patch_dir):
|
||||
assert_no_diff()
|
||||
|
||||
|
||||
def test_intent_to_add(in_git_dir, patch_dir):
|
||||
"""Regression test for #881"""
|
||||
_write(b'hello\nworld\n')
|
||||
cmd_output('git', 'add', '--intent-to-add', 'foo')
|
||||
|
||||
assert git.intent_to_add_files() == ['foo']
|
||||
with staged_files_only(patch_dir):
|
||||
assert_no_diff()
|
||||
assert git.intent_to_add_files() == ['foo']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue