Cloner: use cache if dest exists

The logic to decide whether or not to use the cache attempted to
detect whether the repo had previously been cloned.  It only did
that by checking whether the destination directory exists.  However,
it's perfectly valid for the dest dir to exist if it is empty.
Adjust the check to look for a .git dir within the dest dir to decide
if the repo has already been cloned.

Change-Id: I17926efcf0f38d6229f0e666e53e6730f455d8ef
This commit is contained in:
James E. Blair 2016-02-20 09:19:19 -08:00
parent 208eb6618a
commit 0a6a0c422c
1 changed files with 2 additions and 1 deletions

View File

@ -70,9 +70,10 @@ class Cloner(object):
# Check for a cached git repo first
git_cache = '%s/%s' % (self.cache_dir, project)
git_upstream = '%s/%s' % (self.git_url, project)
repo_is_cloned = os.path.exists(os.path.join(dest, '.git'))
if (self.cache_dir and
os.path.exists(git_cache) and
not os.path.exists(dest)):
not repo_is_cloned):
# file:// tells git not to hard-link across repos
git_cache = 'file://%s' % git_cache
self.log.info("Creating repo %s from cache %s",