summaryrefslogtreecommitdiff
path: root/tests/testutils/repo
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2018-02-02 16:19:42 +0000
committerJürg Billeter <j@bitron.ch>2018-02-19 15:17:00 +0000
commit6498020e1e0414f7e235421ddf68400da32f55a2 (patch)
treef765311a6e50c4f59ced85dc0b2b9974915631a1 /tests/testutils/repo
parentd94125fe7110c71b127199206834c89b5189942d (diff)
downloadbuildstream-6498020e1e0414f7e235421ddf68400da32f55a2.tar.gz
testutils: Add support for git source controlling submodule checkout
Diffstat (limited to 'tests/testutils/repo')
-rw-r--r--tests/testutils/repo/git.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/testutils/repo/git.py b/tests/testutils/repo/git.py
index c5f85ba32..2a20bc331 100644
--- a/tests/testutils/repo/git.py
+++ b/tests/testutils/repo/git.py
@@ -36,13 +36,18 @@ class Git(Repo):
env=GIT_ENV, cwd=self.repo)
return self.latest_commit()
- def add_submodule(self, subdir, url):
- self.submodules[subdir] = url
+ def add_submodule(self, subdir, url=None, checkout=None):
+ submodule = {}
+ if checkout is not None:
+ submodule['checkout'] = checkout
+ if url is not None:
+ submodule['url'] = url
+ self.submodules[subdir] = submodule
subprocess.call(['git', 'submodule', 'add', url, subdir], env=GIT_ENV, cwd=self.repo)
subprocess.call(['git', 'commit', '-m', 'Added the submodule'], env=GIT_ENV, cwd=self.repo)
return self.latest_commit()
- def source_config(self, ref=None):
+ def source_config(self, ref=None, checkout_submodules=None):
config = {
'kind': 'git',
'url': 'file://' + self.repo,
@@ -50,11 +55,11 @@ class Git(Repo):
}
if ref is not None:
config['ref'] = ref
+ if checkout_submodules is not None:
+ config['checkout-submodules'] = checkout_submodules
if self.submodules:
- config['submodules'] = {}
- for subdir, url in self.submodules.items():
- config['submodules'][subdir] = {'url': url}
+ config['submodules'] = dict(self.submodules)
return config