File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 10
10
11
11
import os
12
12
13
+ import git .repo .fun
14
+
13
15
14
16
def dir_exists (dirpath ):
15
17
"""Tests for existence of a directory on the string filepath"""
@@ -44,8 +46,16 @@ def get_git_root_path(filepath):
44
46
45
47
# search up to five directories above for the git repo root
46
48
for _ in range (6 ):
47
- if dir_exists (os .path .join (gitroot_path , ".git" )):
49
+ dot_git = os .path .join (gitroot_path , ".git" )
50
+ if git .repo .fun .is_git_dir (dot_git ):
48
51
return gitroot_path
52
+ elif file_exists (dot_git ):
53
+ # Returns something like ".../font-v/.git/worktrees/work-worktrees-work"
54
+ worktree_path = git .repo .fun .find_worktree_git_dir (dot_git )
55
+ if worktree_path :
56
+ # ".../font-v/.git/worktrees/work-worktrees-work" -> ".../font-v"
57
+ return worktree_path .split ("/.git/worktrees/" , 2 )[0 ]
58
+
49
59
gitroot_path = os .path .dirname (gitroot_path )
50
60
51
61
raise IOError (
You can’t perform that action at this time.
0 commit comments