1
0
mirror of https://github.com/wting/autojump synced 2024-09-28 22:10:45 +00:00

added recursion to find git repository

This commit is contained in:
Pierre Gueth 2009-03-27 12:25:14 +01:00
parent 9b87282791
commit 43389f2924

View File

@ -22,9 +22,15 @@ def action(validator,name=None):
return wrapper return wrapper
#validator helper #validator helper
def has_child_dir(dirname): def has_child_dir(dirname,recursion=0):
def wrapper(path): def wrapper(path):
return os.path.isdir(os.path.join(path,dirname)) k=recursion
ii=""
while k>=0:
if os.path.isdir(os.path.join(path,ii,dirname)): return True
k-=1
ii=os.path.join("..",ii)
return False
return wrapper return wrapper
@ -90,7 +96,7 @@ def quit(sender):
###################################################### ######################################################
#insert other actions here using the action decorator# #insert other actions here using the action decorator#
###################################################### ######################################################
@action(has_child_dir(".git")) @action(has_child_dir(".git",recursion=3))
def gitk(sender,path): def gitk(sender,path):
if not os.fork(): if not os.fork():
os.chdir(path) os.chdir(path)