import os
-class BaseDirException(Exception):
- pass
-
def __output(cmd):
f = os.popen(cmd, 'r')
string = f.readline().rstrip()
if f.close():
- raise BaseDirException, 'Error: failed to execute "%s"' % cmd
+ return ''
return string
# GIT_DIR value cached
if 'GIT_DIR' in os.environ:
__base_dir = os.environ['GIT_DIR']
else:
- __base_dir = __output('git-rev-parse --git-dir')
+ __base_dir = __output('git-rev-parse --git-dir 2> /dev/null')
return __base_dir
+
+def clear_cache():
+ """Clear the cached location of .git
+ """
+ global __base_dir
+ __base_dir = None