Merging upstream version 2.10.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
22fa9cbff7
commit
49934447ef
17 changed files with 286 additions and 39 deletions
|
@ -3,6 +3,7 @@ import os.path
|
|||
import pytest
|
||||
|
||||
from pre_commit import git
|
||||
from pre_commit.error_handler import FatalError
|
||||
from pre_commit.util import cmd_output
|
||||
from testing.util import git_commit
|
||||
|
||||
|
@ -18,6 +19,25 @@ def test_get_root_deeper(in_git_dir):
|
|||
assert os.path.normcase(git.get_root()) == expected
|
||||
|
||||
|
||||
def test_in_exactly_dot_git(in_git_dir):
|
||||
with in_git_dir.join('.git').as_cwd(), pytest.raises(FatalError):
|
||||
git.get_root()
|
||||
|
||||
|
||||
def test_get_root_bare_worktree(tmpdir):
|
||||
src = tmpdir.join('src').ensure_dir()
|
||||
cmd_output('git', 'init', str(src))
|
||||
git_commit(cwd=str(src))
|
||||
|
||||
bare = tmpdir.join('bare.git').ensure_dir()
|
||||
cmd_output('git', 'clone', '--bare', str(src), str(bare))
|
||||
|
||||
cmd_output('git', 'worktree', 'add', 'foo', 'HEAD', cwd=bare)
|
||||
|
||||
with bare.join('foo').as_cwd():
|
||||
assert git.get_root() == os.path.abspath('.')
|
||||
|
||||
|
||||
def test_get_staged_files_deleted(in_git_dir):
|
||||
in_git_dir.join('test').ensure()
|
||||
cmd_output('git', 'add', 'test')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue