summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2016-03-14 17:57:01 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2016-03-14 17:57:01 +0000
commit5ce3065364b021b5f3c8664f4e16fbcd3cf52cb6 (patch)
treea0e16b66015d34f8827b94403cb9dd6ac9ff703d
parent23c021346571c24fa26eb348f573bab72fa257d9 (diff)
downloadmorph-sam/one-repo-cache.tar.gz
Tests pass.. must be finished :-)sam/one-repo-cache
Change-Id: Ia8e42c8171437638ed44fc200e587940b5507b56
-rw-r--r--morphlib/builder_tests.py2
-rw-r--r--morphlib/repocache.py9
-rw-r--r--morphlib/repocache_tests.py13
3 files changed, 13 insertions, 11 deletions
diff --git a/morphlib/builder_tests.py b/morphlib/builder_tests.py
index da1f432e..54bc4a8f 100644
--- a/morphlib/builder_tests.py
+++ b/morphlib/builder_tests.py
@@ -51,7 +51,7 @@ class FakeSource(object):
self.name = 'a'
with morphlib.gitdir_tests.allow_nonexistant_git_repos():
- self.repo = morphlib.localrepocache.CachedRepo(
+ self.repo = morphlib.repocache.CachedRepo(
'path', 'repo', 'url')
self.repo_name = 'url'
self.original_ref = 'e'
diff --git a/morphlib/repocache.py b/morphlib/repocache.py
index 58e05129..45d9807d 100644
--- a/morphlib/repocache.py
+++ b/morphlib/repocache.py
@@ -245,6 +245,9 @@ class RepoCache(object):
return True, None
+ def _new_cached_repo_instance(self, reponame, repourl, path):
+ return CachedRepo(reponame, repourl, path)
+
def _cache_repo(self, reponame):
'''Clone the given repo into the cache.
@@ -292,7 +295,7 @@ class RepoCache(object):
repourl = self._resolver.pull_url(reponame)
path = self._cache_name(repourl)
if self.fs.exists(path):
- repo = CachedRepo(path, reponame, repourl)
+ repo = self._new_cached_repo_instance(path, reponame, repourl)
self._cached_repo_objects[reponame] = repo
return repo
elif self.update_gits:
@@ -303,7 +306,7 @@ class RepoCache(object):
def _update_repo(self, cachedrepo): # pragma: no cover
try:
cachedrepo.update_remotes(
- echo_stderr=self._app.settings['verbose'])
+ echo_stderr=self.verbose)
cachedrepo.already_updated = True
except cliapp.AppException:
raise UpdateError(self)
@@ -420,7 +423,7 @@ class RepoCache(object):
return absref, ref
-class RemoteResolveRefError(cliapp.AppException):
+class RemoteResolveRefError(cliapp.AppException): # pragma: no cover
def __init__(self, repo_name, ref):
cliapp.AppException.__init__(
diff --git a/morphlib/repocache_tests.py b/morphlib/repocache_tests.py
index 32af4591..9605a177 100644
--- a/morphlib/repocache_tests.py
+++ b/morphlib/repocache_tests.py
@@ -84,11 +84,9 @@ class TestableRepoCache(morphlib.repocache.RepoCache):
else:
raise NotImplementedError()
- def _new_cached_repo_instance(self, *args, **kwargs):
- with morphlib.gitdir_tests.allow_nonexistant_git_repos():
- repo = morphlib.cachedrepo.CachedRepo(*args, **kwargs)
- repo.update = lambda: None
- return repo
+ def _update_repo(self, cached_repo):
+ pass
+
class RepoCacheTests(unittest.TestCase):
@@ -153,8 +151,9 @@ class RepoCacheTests(unittest.TestCase):
repo_cache = TestableRepoCache()
repo_cache.fs.makedir('/local/repo', recursive=True)
- cached = repo_cache.get_updated_repo('file:///local/repo', refs='master')
- assert cached.path == '/local/repo'
+ with morphlib.gitdir_tests.allow_nonexistant_git_repos():
+ cached = repo_cache.get_updated_repo('file:///local/repo', refs='master')
+ assert cached.dirname == '/local/repo'
def test_no_git_update_setting(self):
repo_cache = TestableRepoCache(update_gits=False)