summaryrefslogtreecommitdiffstats
path: root/tests/git_test.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-30 06:41:17 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-30 06:41:24 +0000
commitfa5ef2f7043154e9abd97282e0c876539b5b1bb0 (patch)
tree2ac7c3546a5158f101fe6c18261fbd3df33b6343 /tests/git_test.py
parentReleasing progress-linux version 2.9.3-1. (diff)
downloadpre-commit-fa5ef2f7043154e9abd97282e0c876539b5b1bb0.tar.xz
pre-commit-fa5ef2f7043154e9abd97282e0c876539b5b1bb0.zip
Merging upstream version 2.10.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/git_test.py')
-rw-r--r--tests/git_test.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/git_test.py b/tests/git_test.py
index fafd4a6..69fd206 100644
--- a/tests/git_test.py
+++ b/tests/git_test.py
@@ -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')