Make VCS guess() function respect .git files

Closes #67.
This commit is contained in:
ZyX 2013-01-19 17:25:37 +04:00 committed by Kim Silkebækken
parent 0acfd8437a
commit 06d4b4555f
1 changed files with 5 additions and 2 deletions

View File

@ -13,11 +13,14 @@ def generate_directories(path):
yield path
vcs_props = (('git', '.git', os.path.exists),
('mercurial', '.hg', os.path.isdir))
@memoize(100)
def guess(path):
for directory in generate_directories(path):
for vcs, vcs_dir in (('git', '.git'), ('mercurial', '.hg')):
if os.path.isdir(os.path.join(directory, vcs_dir)):
for vcs, vcs_dir, check in vcs_props:
if check(os.path.join(directory, vcs_dir)):
try:
if vcs not in globals():
globals()[vcs] = importlib.import_module('powerline.lib.vcs.' + vcs)