From f97653aa06cf84bcf160be3786b6fce49ef52961 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 15 Nov 2010 18:42:44 +0100 Subject: Repo: added submodule query and iteration methods similar to the ones provided for Remotes, including test --- test/git/test_repo.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/git/test_repo.py') diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 65dce590..063b5dff 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -208,8 +208,10 @@ class TestRepo(TestBase): assert_equal('' % path, repr(self.rorepo)) def test_is_dirty_with_bare_repository(self): + orig_value = self.rorepo._bare self.rorepo._bare = True assert_false(self.rorepo.is_dirty()) + self.rorepo._bare = orig_value def test_is_dirty(self): self.rorepo._bare = False @@ -220,8 +222,10 @@ class TestRepo(TestBase): # END untracked files # END working tree # END index + orig_val = self.rorepo._bare self.rorepo._bare = True assert self.rorepo.is_dirty() == False + self.rorepo._bare = orig_val def test_head(self): assert self.rorepo.head.reference.object == self.rorepo.active_branch.object @@ -552,3 +556,9 @@ class TestRepo(TestBase): target_type = GitCmdObjectDB assert isinstance(self.rorepo.odb, target_type) + def test_submodules(self): + assert len(self.rorepo.submodules) == 1 # non-recursive + assert len(self.rorepo.list_submodules(recursive=True)) == 2 + + assert isinstance(self.rorepo.submodule("lib/git/ext/gitdb"), Submodule) + self.failUnlessRaises(ValueError, self.rorepo.submodule, "doesn't exist") -- cgit v1.2.1 From 624556eae1c292a1dc283d9dca1557e28abe8ee3 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 15 Nov 2010 19:03:53 +0100 Subject: Optimized test-decorators, by completely removing with_bare_rw_repo, which was mainly copy-paste from with_rw_repo, what a shame --- test/git/test_repo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/git/test_repo.py') diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 063b5dff..3a59f05e 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -558,7 +558,7 @@ class TestRepo(TestBase): def test_submodules(self): assert len(self.rorepo.submodules) == 1 # non-recursive - assert len(self.rorepo.list_submodules(recursive=True)) == 2 + assert len(list(self.rorepo.iter_submodules())) == 2 assert isinstance(self.rorepo.submodule("lib/git/ext/gitdb"), Submodule) self.failUnlessRaises(ValueError, self.rorepo.submodule, "doesn't exist") -- cgit v1.2.1 From a1e6234c27abf041e4c8cd1a799950e7cd9104f6 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 17 Nov 2010 15:24:48 +0100 Subject: Inital implementation of Submodule.move including a very simple and to-be-improved test --- test/git/test_repo.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/git/test_repo.py') diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 3a59f05e..2acccced 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -562,3 +562,12 @@ class TestRepo(TestBase): assert isinstance(self.rorepo.submodule("lib/git/ext/gitdb"), Submodule) self.failUnlessRaises(ValueError, self.rorepo.submodule, "doesn't exist") + + @with_rw_repo('HEAD', bare=False) + def test_submodule_update(self, rwrepo): + # fails in bare mode + rwrepo._bare = True + self.failUnlessRaises(InvalidGitRepositoryError, rwrepo.submodule_update) + rwrepo._bare = False + + -- cgit v1.2.1 From 7cc4d748a132377ffe63534e9777d7541a3253c5 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 17 Nov 2010 21:33:33 +0100 Subject: repo: Added create_submodule method which fits into the tradition of offering a create_* method for most important entities. Moved implementation of smart update method to the RootModule implementation, where it may do special things without requiring an interface for everything --- test/git/test_repo.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/git/test_repo.py') diff --git a/test/git/test_repo.py b/test/git/test_repo.py index 2acccced..fb6e1450 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -570,4 +570,9 @@ class TestRepo(TestBase): self.failUnlessRaises(InvalidGitRepositoryError, rwrepo.submodule_update) rwrepo._bare = False + # test create submodule + sm = rwrepo.submodules[0] + sm = rwrepo.create_submodule("my_new_sub", "some_path", join_path_native(self.rorepo.working_tree_dir, sm.path)) + assert isinstance(sm, Submodule) + -- cgit v1.2.1 From 0c1834134ce177cdbd30a56994fcc4bf8f5be8b2 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 18 Nov 2010 11:41:16 +0100 Subject: Added test-setup which can test all aspects of the (smart) update method --- test/git/test_repo.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/git/test_repo.py') diff --git a/test/git/test_repo.py b/test/git/test_repo.py index fb6e1450..a6047bf5 100644 --- a/test/git/test_repo.py +++ b/test/git/test_repo.py @@ -575,4 +575,6 @@ class TestRepo(TestBase): sm = rwrepo.create_submodule("my_new_sub", "some_path", join_path_native(self.rorepo.working_tree_dir, sm.path)) assert isinstance(sm, Submodule) + # note: the rest of this functionality is tested in test_submodule + -- cgit v1.2.1