diff options
-rw-r--r-- | morphlib/cachedrepo.py | 26 | ||||
-rw-r--r-- | morphlib/cachedrepo_tests.py | 28 |
2 files changed, 27 insertions, 27 deletions
diff --git a/morphlib/cachedrepo.py b/morphlib/cachedrepo.py index a630cc29..93bb357e 100644 --- a/morphlib/cachedrepo.py +++ b/morphlib/cachedrepo.py @@ -91,11 +91,11 @@ class CachedRepo(object): self.is_mirror = not url.startswith('file://') self.already_updated = False - self._gitdir = morphlib.gitdir.GitDirectory(path) + self.gitdir = morphlib.gitdir.GitDirectory(path) def ref_exists(self, ref): # pragma: no cover '''Returns True if the given ref exists in the repo''' - return self._gitdir.ref_exists(ref) + return self.gitdir.ref_exists(ref) def resolve_ref_to_commit(self, ref): # pragma: no cover '''Resolve a named ref to a commit SHA1. @@ -103,7 +103,7 @@ class CachedRepo(object): Raises gitdir.InvalidRefError if the ref does not exist. ''' - return self._gitdir.resolve_ref_to_commit(ref) + return self.gitdir.resolve_ref_to_commit(ref) def resolve_ref_to_tree(self, ref): # pragma: no cover '''Resolve a named ref to a tree SHA1. @@ -111,7 +111,7 @@ class CachedRepo(object): Raises gitdir.InvalidRefError if the ref does not exist. ''' - return self._gitdir.resolve_ref_to_tree(ref) + return self.gitdir.resolve_ref_to_tree(ref) def read_file(self, filename, ref): # pragma: no cover '''Attempts to read a file from a given ref. @@ -121,7 +121,7 @@ class CachedRepo(object): the ref. ''' - return self._gitdir.read_file(filename, ref) + return self.gitdir.read_file(filename, ref) def tags_containing_sha1(self, ref): # pragma: no cover '''Check whether given sha1 is contained in any tags @@ -131,7 +131,7 @@ class CachedRepo(object): a sha1. ''' - return self._gitdir.tags_containing_sha1(ref) + return self.gitdir.tags_containing_sha1(ref) def branches_containing_sha1(self, ref): # pragma: no cover '''Check whether given sha1 is contained in any branches @@ -141,7 +141,7 @@ class CachedRepo(object): a sha1. ''' - return self._gitdir.branches_containing_sha1(ref) + return self.gitdir.branches_containing_sha1(ref) def version_guess(self, ref): # pragma: no cover '''Guess version number using `git describe --tags` @@ -159,7 +159,7 @@ class CachedRepo(object): repository. ''' - return self._gitdir.list_files(ref, recurse) + return self.gitdir.list_files(ref, recurse) def clone_checkout(self, ref, target_dir): '''Clone from the cache into the target path and check out a given ref. @@ -175,7 +175,7 @@ class CachedRepo(object): if os.path.exists(target_dir): raise CheckoutDirectoryExistsError(self, target_dir) - self._gitdir.resolve_ref_to_commit(ref) + self.gitdir.resolve_ref_to_commit(ref) self._clone_into(target_dir, ref) @@ -217,7 +217,7 @@ class CachedRepo(object): os.makedirs(target_dir) with tempfile.NamedTemporaryFile() as index_file: - index = self._gitdir.get_index(index_file=index_file.name) + index = self.gitdir.get_index(index_file=index_file.name) index.set_to_tree(ref) index.checkout(working_tree=target_dir) @@ -240,7 +240,7 @@ class CachedRepo(object): # Named refs that are valid SHA1s will confuse this code. ref_can_change = not morphlib.git.is_valid_sha1(ref) - if ref_can_change or not self._gitdir.ref_exists(ref): + if ref_can_change or not self.gitdir.ref_exists(ref): return True else: return False @@ -257,7 +257,7 @@ class CachedRepo(object): return try: - self._gitdir.update_remotes( + self.gitdir.update_remotes( echo_stderr=self.app.settings['debug']) self.already_updated = True except cliapp.AppException: @@ -285,7 +285,7 @@ class CachedRepo(object): def _checkout_ref_in_clone(self, ref, clone_dir): # pragma: no cover # This is a separate GitDirectory instance. Don't confuse it with the - # internal ._gitdir attribute! + # internal .gitdir attribute! working_gitdir = morphlib.gitdir.GitDirectory(clone_dir) try: working_gitdir.checkout(ref) diff --git a/morphlib/cachedrepo_tests.py b/morphlib/cachedrepo_tests.py index da88dab4..d32ce2eb 100644 --- a/morphlib/cachedrepo_tests.py +++ b/morphlib/cachedrepo_tests.py @@ -110,7 +110,7 @@ class CachedRepoTests(unittest.TestCase): self.assertEqual(self.repo.path, self.repo_path) def test_fail_clone_checkout_into_existing_directory(self): - self.repo._gitdir.checkout = self.checkout_ref + self.repo.gitdir.checkout = self.checkout_ref self.repo._clone_into = self.clone_into self.assertRaises(morphlib.cachedrepo.CheckoutDirectoryExistsError, @@ -119,7 +119,7 @@ class CachedRepoTests(unittest.TestCase): self.tempfs.root_path) def test_fail_checkout_due_to_clone_error(self): - self.repo._gitdir._rev_parse = self.rev_parse + self.repo.gitdir._rev_parse = self.rev_parse self.repo._clone_into = self.clone_into self.assertRaises( @@ -128,7 +128,7 @@ class CachedRepoTests(unittest.TestCase): self.tempfs.getsyspath('failed-checkout')) def test_fail_checkout_due_to_copy_error(self): - self.repo._gitdir._rev_parse = self.rev_parse + self.repo.gitdir._rev_parse = self.rev_parse self.repo._copy_repository = self.copy_repository self.assertRaises(morphlib.cachedrepo.CopyError, self.repo.checkout, @@ -136,7 +136,7 @@ class CachedRepoTests(unittest.TestCase): self.tempfs.getsyspath('failed-checkout')) def test_fail_checkout_from_invalid_ref(self): - self.repo._gitdir._rev_parse = self.rev_parse + self.repo.gitdir._rev_parse = self.rev_parse self.repo._copy_repository = self.copy_repository self.repo._checkout_ref_in_clone = self.checkout_ref @@ -146,7 +146,7 @@ class CachedRepoTests(unittest.TestCase): self.tempfs.getsyspath('checkout-from-invalid-ref')) def test_checkout_from_existing_ref_into_new_directory(self): - self.repo._gitdir._rev_parse = self.rev_parse + self.repo.gitdir._rev_parse = self.rev_parse self.repo._copy_repository = self.copy_repository self.repo._checkout_ref_in_clone = self.checkout_ref @@ -159,7 +159,7 @@ class CachedRepoTests(unittest.TestCase): self.assertTrue(os.path.exists(morph_filename)) def test_extract_commit_into_new_directory(self): - self.repo._gitdir.get_index = self.get_index + self.repo.gitdir.get_index = self.get_index unpack_dir = self.tempfs.getsyspath('unpack-dir') self.repo.extract_commit('e28a23812eadf2fce6583b8819b9c5dbd36b9fb9', unpack_dir) @@ -169,25 +169,25 @@ class CachedRepoTests(unittest.TestCase): self.assertTrue(os.path.exists(morph_filename)) def test_successful_update(self): - self.repo._gitdir.update_remotes = self.update_successfully + self.repo.gitdir.update_remotes = self.update_successfully self.repo.update() def test_failing_update(self): - self.repo._gitdir.update_remotes = self.update_with_failure + self.repo.gitdir.update_remotes = self.update_with_failure self.assertRaises(morphlib.cachedrepo.UpdateError, self.repo.update) def test_no_update_if_local(self): with morphlib.gitdir_tests.allow_nonexistant_git_repos(): self.repo = morphlib.cachedrepo.CachedRepo( object(), 'local:repo', 'file:///local/repo/', '/local/repo/') - self.repo._gitdir.update_remotes = self.update_with_failure - self.repo._gitdir._rev_parse = self.rev_parse + self.repo.gitdir.update_remotes = self.update_with_failure + self.repo.gitdir._rev_parse = self.rev_parse self.assertFalse(self.repo.requires_update_for_ref(self.known_commit)) self.repo.update() def test_clone_checkout(self): - self.repo._gitdir._rev_parse = self.rev_parse + self.repo.gitdir._rev_parse = self.rev_parse self.repo._clone_into = self.clone_into self.repo.clone_checkout('master', '/.DOES_NOT_EXIST') @@ -198,14 +198,14 @@ class CachedRepoTests(unittest.TestCase): # If the SHA1 is present locally already there's no need to update. # If it's a named ref then it might have changed in the remote, so we # must still update. - self.repo._gitdir._rev_parse = self.rev_parse + self.repo.gitdir._rev_parse = self.rev_parse self.assertFalse(self.repo.requires_update_for_ref(self.known_commit)) self.assertTrue(self.repo.requires_update_for_ref('named_ref')) def test_no_need_to_update_repo_if_already_updated(self): - self.repo._gitdir.update_remotes = self.update_successfully - self.repo._gitdir._rev_parse = self.rev_parse + self.repo.gitdir.update_remotes = self.update_successfully + self.repo.gitdir._rev_parse = self.rev_parse self.assertTrue(self.repo.requires_update_for_ref('named_ref')) self.repo.update() |