From 36d13cb75dbcf321a3e882f4b3378f4833404294 Mon Sep 17 00:00:00 2001 From: Markus Lehtonen Date: Thu, 12 Jul 2012 11:26:55 +0300 Subject: GitRepository/get_submodules: use correct path By default, run git in the repo path, not current cwd. Also, now returns submodule paths without leading './'. Signed-off-by: Markus Lehtonen --- gbp/git/repository.py | 7 ++++--- tests/04_test_submodules.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gbp/git/repository.py b/gbp/git/repository.py index a855ac7..b2df4ea 100644 --- a/gbp/git/repository.py +++ b/gbp/git/repository.py @@ -1497,7 +1497,7 @@ class GitRepository(object): # the latter. submodules = [] if path is None: - path = "." + path = self.path args = [ treeish ] if recursive: @@ -1508,8 +1508,9 @@ class GitRepository(object): mode, objtype, commit, name = line[:-1].split(None, 3) # A submodules is shown as "commit" object in ls-tree: if objtype == "commit": - nextpath = os.path.sep.join([path, name]) - submodules.append( (nextpath, commit) ) + nextpath = os.path.join(path, name) + submodules.append( (nextpath.replace(self.path,'').lstrip('/'), + commit) ) if recursive: submodules += self.get_submodules(commit, path=nextpath, recursive=recursive) diff --git a/tests/04_test_submodules.py b/tests/04_test_submodules.py index f40bc4d..efcc9aa 100644 --- a/tests/04_test_submodules.py +++ b/tests/04_test_submodules.py @@ -90,7 +90,7 @@ def test_has_submodules(): def test_get_submodules(): """Check for submodules list of (name, hash)""" modules = repo.get_submodules("master")[0] - assert modules[0] == './test_submodule' + assert modules[0] == 'test_submodule' assert len(modules[1]) == 40 -- cgit v1.2.3