diff options
Diffstat (limited to 'git')
-rw-r--r-- | git/objects/submodule/base.py | 2 | ||||
-rw-r--r-- | git/objects/submodule/root.py | 5 | ||||
-rw-r--r-- | git/test/objects/test_submodule.py | 10 |
3 files changed, 9 insertions, 8 deletions
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py index 0fdb121d..a33dd8ad 100644 --- a/git/objects/submodule/base.py +++ b/git/objects/submodule/base.py @@ -89,7 +89,7 @@ class Submodule(util.IndexObject, Iterable, Traversable, RepoAliasMixin): :param repo: Our parent repository :param binsha: binary sha referring to a commit in the remote repository, see url parameter - :param parent_commit: see set_parent_commit() + :param parent_commit: a Commit object instance, see set_parent_commit() for more information :param url: The url to the remote repository which is the submodule :param branch_path: full (relative) path to ref to checkout when cloning the remote repository""" super(Submodule, self).__init__(repo, binsha, mode, path) diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py index 5e4cad2d..6917045a 100644 --- a/git/objects/submodule/root.py +++ b/git/objects/submodule/root.py @@ -37,15 +37,14 @@ class RootModule(Submodule): k_root_name = '__ROOT__' - def __init__(self, repo): - # repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, ref=None) + def __init__(self, repo, parent_commit = None): super(RootModule, self).__init__( repo, binsha = self.NULL_BIN_SHA, mode = self.k_default_mode, path = '', name = self.k_root_name, - parent_commit = repo.head.commit, + parent_commit = parent_commit or repo.head.commit, url = '', branch_path = git.Head.to_full_path(self.k_head_default) ) diff --git a/git/test/objects/test_submodule.py b/git/test/objects/test_submodule.py index 8e22cc6d..530806fb 100644 --- a/git/test/objects/test_submodule.py +++ b/git/test/objects/test_submodule.py @@ -394,15 +394,17 @@ class TestSubmodule(TestObjectBase): @with_rw_repo(k_subm_current, bare=False) def test_root_module(self, rwrepo): # Can query everything without problems - rm = RootModule(self.rorepo) - assert rm.module() is self.rorepo + rm = RootModule(rwrepo) + # test new constructor + assert rm.parent_commit == RootModule(self.rorepo, self.rorepo.commit(self.k_subm_current)).parent_commit + assert rm.module() is rwrepo # try attributes rm.binsha rm.mode rm.path assert rm.name == rm.k_root_name - assert rm.parent_commit == self.rorepo.head.commit + assert rm.parent_commit == self.rorepo.commit(self.k_subm_current) rm.url rm.branch @@ -412,7 +414,7 @@ class TestSubmodule(TestObjectBase): # deep traversal git / async rsmsp = [sm.path for sm in rm.traverse()] - assert len(rsmsp) == 2 # git, async, smmap, async being a child of git. + assert len(rsmsp) == 1 # gitdb only - its not yet uptodate so it has no submodule # cannot set the parent commit as root module's path didn't exist self.failUnlessRaises(ValueError, rm.set_parent_commit, 'HEAD') |