File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 77import re
88from plumbum import local
99
10+ from pre_commit .errors import FatalError
1011from pre_commit .util import memoize_by_cwd
1112
1213
1314logger = logging .getLogger ('pre_commit' )
1415
1516
16- @memoize_by_cwd
1717def get_root ():
1818 path = os .getcwd ()
1919 while len (path ) > 1 :
2020 if os .path .exists (os .path .join (path , '.git' )):
2121 return path
2222 else :
2323 path = os .path .normpath (os .path .join (path , '../' ))
24- raise AssertionError ('called from outside of the gits' )
24+ raise FatalError (
25+ 'Called from outside of the gits. '
26+ 'Please cd to a git repository.'
27+ )
2528
2629
2730def is_in_merge_conflict ():
Original file line number Diff line number Diff line change 66from plumbum import local
77
88from pre_commit import git
9+ from pre_commit .errors import FatalError
910from testing .fixtures import git_dir
1011
1112
@@ -24,6 +25,12 @@ def test_get_root_deeper(tmpdir_factory):
2425 assert git .get_root () == path
2526
2627
28+ def test_get_root_not_git_dir (tmpdir_factory ):
29+ with local .cwd (tmpdir_factory .get ()):
30+ with pytest .raises (FatalError ):
31+ git .get_root ()
32+
33+
2734def test_is_not_in_merge_conflict (tmpdir_factory ):
2835 path = git_dir (tmpdir_factory )
2936 with local .cwd (path ):
You can’t perform that action at this time.
0 commit comments