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 1010
1111import os
1212
13+ import git .repo .fun
14+
1315
1416def dir_exists (dirpath ):
1517 """Tests for existence of a directory on the string filepath"""
@@ -44,8 +46,16 @@ def get_git_root_path(filepath):
4446
4547 # search up to five directories above for the git repo root
4648 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 ):
4851 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+
4959 gitroot_path = os .path .dirname (gitroot_path )
5060
5161 raise IOError (
You can’t perform that action at this time.
0 commit comments