- if os.path.exists(cachedir):
- logging.debug('Checking if we already have rev %s', rev)
- process = subprocess.run(
- ['git', '-C', cachedir, 'cat-file', '-e', rev], check=False)
- if process.returncode == 0:
- logging.debug('We already have rev %s', rev)
- verify_ancestry(repo, ref, rev)
- return cachedir
- if process.returncode != 1:
- raise Exception(
- 'Could not test for presence of rev %s. Is cache dir "%s" messed up?' %
- (rev, cachedir))