def is_git(directory): """ Checks if a directory is a local git repo """ directory = os.path.abspath(directory) dir = directory.split('/') while len(dir) > 1: path = '/'.join(dir) gitconfig = os.path.join(path, '.git', 'config') if os.path.isfile(gitconfig): return True # if there is .svn (but no .git) it is a .svn directory and # do not have to continue walking up... if svn.is_subversion(path): return False dir.pop() return False
def is_git_svn(directory): directory = os.path.abspath(directory) dir = directory.split('/') while len(dir)>1: path = '/'.join(dir) gitconfig = os.path.join(path, '.git', 'config') if os.path.isfile(gitconfig) and '[svn-remote' in open(gitconfig).read(): # check if the remote really works. maybe we have just migrated the package # and do not use the svn remote any more foo, out, err = runcmd_with_exitcode('cd %s ; git svn info' % path, log=False, respond=True, respond_error=True) if len(err.strip()): output.error('Your svn remote is not working. Fix it or ' 'remove it. (%s)' % directory, exit=True) return True # if there is .svn (but no .git) it is a .svn directory and # do not have to continue walking up... if svn.is_subversion(path): return False dir.pop() return False