diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-09-03 22:20:48 -0400 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-09-04 04:04:11 -0400 |
commit | 15db6d56ec6617b96f0ec8966345fccd2a557617 (patch) | |
tree | 647c6c4736430d9a8130fc0a3bce77ef03992dd4 /tests/testutils/repo/bzr.py | |
parent | 00bc9d3abae0abe731ab3f57a450800c6a27df00 (diff) | |
download | buildstream-15db6d56ec6617b96f0ec8966345fccd2a557617.tar.gz |
tests/testutils/repo module: New module for Source support scaffolding
Currently comes with a Repo() abstract class and a git implementation
Diffstat (limited to 'tests/testutils/repo/bzr.py')
-rw-r--r-- | tests/testutils/repo/bzr.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/testutils/repo/bzr.py b/tests/testutils/repo/bzr.py new file mode 100644 index 000000000..848cff85f --- /dev/null +++ b/tests/testutils/repo/bzr.py @@ -0,0 +1,42 @@ +import os +import shutil +import subprocess +from .repo import Repo + +BZR_ENV = { + "BZR_EMAIL": "Testy McTesterson <testy.mctesterson@example.com>" +} + + +class Bzr(Repo): + + def create(self, directory): + branch_dir = os.path.join(self.repo, 'trunk') + + subprocess.call(['bzr', 'init-repo', self.repo], env=BZR_ENV) + subprocess.call(['bzr', 'init', branch_dir], env=BZR_ENV) + self.copy_directory(directory, branch_dir) + subprocess.call(['bzr', 'add', '.'], env=BZR_ENV, cwd=branch_dir) + subprocess.call(['bzr', 'commit', '--message="Initial commit"'], + env=BZR_ENV, cwd=branch_dir) + + return self.latest_commit() + + def source_config(self, ref=None): + config = { + 'kind': 'bzr', + 'url': 'file://' + self.repo, + 'track': 'trunk' + } + if ref is not None: + config['ref'] = ref + + return config + + def latest_commit(self): + output = subprocess.check_output([ + 'bzr', 'version-info', + '--custom', '--template={revno}', + os.path.join(self.repo, 'trunk') + ], env=BZR_ENV) + return output.decode('UTF-8').strip() |