@@ -33,39 +33,24 @@ def file_exists(filepath):
3333
3434def get_git_root_path (filepath ):
3535 """
36- Recursively searches for git root path over 4 directory levels above working directory
36+ Recursively searches for git root path over 5 directory levels above working directory
3737 :param filepath: (string) - path to the font file that is under git version control
3838 :return: validated git root path as string
3939 :raises: IOError if unable to detect the root of the git repository through this path traversal
4040 """
4141
4242 # begin by defining directory that contains font as the git root needle
43- unverified_gitroot_path = os .path .dirname (os .path .abspath (filepath ))
43+ gitroot_path = os .path .dirname (os .path .abspath (filepath ))
4444
45- # check to see if this assumption is correct
46- if dir_exists (os .path .join (unverified_gitroot_path , ".git" )):
47- verified_gitroot_path = unverified_gitroot_path
48- else : # if not, recursive search up to three directories above for the git repo root
49- one_level_up = os .path .abspath (os .path .join (unverified_gitroot_path , os .pardir ))
50- two_levels_up = os .path .dirname (one_level_up )
51- three_levels_up = os .path .dirname (two_levels_up )
45+ # search up to five directories above for the git repo root
46+ for _ in range (6 ):
47+ if dir_exists (os .path .join (gitroot_path , ".git" )):
48+ return gitroot_path
49+ gitroot_path = os .path .dirname (gitroot_path )
5250
53- one_level_up_path = os .path .join (one_level_up , ".git" )
54- two_levels_up_path = os .path .join (two_levels_up , ".git" )
55- three_levels_up_path = os .path .join (three_levels_up , ".git" )
56-
57- if dir_exists (one_level_up_path ): # check one directory level up
58- verified_gitroot_path = os .path .dirname (one_level_up_path )
59- elif dir_exists (two_levels_up_path ): # check two directory levels up
60- verified_gitroot_path = os .path .dirname (two_levels_up_path )
61- elif dir_exists (three_levels_up_path ): # check three directory levels up
62- verified_gitroot_path = os .path .dirname (three_levels_up_path )
63- else :
64- raise IOError (
65- "Unable to determine git repository root for font file " + filepath
66- )
67-
68- return verified_gitroot_path
51+ raise IOError (
52+ "Unable to determine git repository root for font file " + filepath
53+ )
6954
7055
7156def is_font (filepath ):
0 commit comments