File tree 2 files changed +13
-0
lines changed 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,11 @@ def get_git_root_path(filepath):
41
41
:raises: IOError if unable to detect the root of the git repository through this path traversal
42
42
"""
43
43
44
+ if "GIT_DIR" in os .environ :
45
+ dot_git = os .path .abspath (os .environ ["GIT_DIR" ])
46
+ if git .repo .fun .is_git_dir (dot_git ):
47
+ return os .path .dirname (dot_git )
48
+
44
49
# begin by defining directory that contains font as the git root needle
45
50
gitroot_path = os .path .dirname (os .path .abspath (filepath ))
46
51
Original file line number Diff line number Diff line change @@ -88,6 +88,14 @@ def test_utilities_get_gitrootpath_function_raises_ioerror_six_levels_up():
88
88
get_git_root_path (filepath )
89
89
90
90
91
+ def test_utilities_get_gitrootpath_uses_git_dir_env_var ():
92
+ os .environ ["GIT_DIR" ] = os .path .abspath (".git" )
93
+ filepath = "/this/isnt/even/a/path/but/it/doesnt/matter"
94
+ gitdir_path = get_git_root_path (filepath )
95
+ assert os .path .basename (gitdir_path ) == "font-v"
96
+ assert os .path .isdir (gitdir_path ) is True
97
+
98
+
91
99
def test_utilities_is_font_ttf ():
92
100
assert is_font ("Test-Regular.ttf" ) is True
93
101
You can’t perform that action at this time.
0 commit comments