File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Expand file tree Collapse file tree 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):
4141 :raises: IOError if unable to detect the root of the git repository through this path traversal
4242 """
4343
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+
4449 # begin by defining directory that contains font as the git root needle
4550 gitroot_path = os .path .dirname (os .path .abspath (filepath ))
4651
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():
8888 get_git_root_path (filepath )
8989
9090
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+
9199def test_utilities_is_font_ttf ():
92100 assert is_font ("Test-Regular.ttf" ) is True
93101
You can’t perform that action at this time.
0 commit comments