aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>2012-07-12 11:26:55 +0300
committerGuido Günther <agx@sigxcpu.org>2012-11-23 19:26:36 +0100
commit36d13cb75dbcf321a3e882f4b3378f4833404294 (patch)
tree565490dd39d88b04c475dda19671be91713af33e
parent8bc79214f5e8dc4dfe8307a1caf8464464727493 (diff)
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 <markus.lehtonen@linux.intel.com>
-rw-r--r--gbp/git/repository.py7
-rw-r--r--tests/04_test_submodules.py2
2 files changed, 5 insertions, 4 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index a855ac72..b2df4eaf 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 f40bc4d1..efcc9aaa 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