File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 66from pre_commit .util import memoize_by_cwd
77
88
9+ def _get_root_original ():
10+ return local ['git' ]['rev-parse' , '--show-toplevel' ]().strip ()
11+
12+ def _get_root_new ():
13+ path = os .getcwd ()
14+ while len (path ) > 1 :
15+ if os .path .exists (os .path .join (path , '.git' )):
16+ return path
17+ else :
18+ path = os .path .normpath (os .path .join (path , '../' ))
19+ raise AssertionError ('called from outside of the gits' )
20+
21+
922@memoize_by_cwd
1023def get_root ():
24+ return _get_root_new ()
1125 return local ['git' ]['rev-parse' , '--show-toplevel' ]().strip ()
1226
1327
Original file line number Diff line number Diff line change 1010def get_pre_commit_dir_path ():
1111 return os .path .join (git .get_root (), C .HOOKS_WORKSPACE )
1212
13+
1314@contextlib .contextmanager
1415def in_hooks_workspace ():
1516 """Change into the hooks workspace. If it does not exist create it."""
You can’t perform that action at this time.
0 commit comments