diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-03-21 22:06:33 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2018-03-22 00:58:40 +0900 |
commit | 0f62dd05c9aaf6cb7e055f6d3cde375aa5998f47 (patch) | |
tree | 9266ff11ab13a612a46a578c171f4003e7d103c4 /tests/testutils/repo | |
parent | d246403e584969bcdac4a2d87ad64aaeab2ac850 (diff) | |
download | buildstream-0f62dd05c9aaf6cb7e055f6d3cde375aa5998f47.tar.gz |
tests/testutils/repo/git.py: Add new add_file() convenience
To write tests which add and commit a file.
Diffstat (limited to 'tests/testutils/repo')
-rw-r--r-- | tests/testutils/repo/git.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/testutils/repo/git.py b/tests/testutils/repo/git.py index 9d527f904..eea43d608 100644 --- a/tests/testutils/repo/git.py +++ b/tests/testutils/repo/git.py @@ -1,5 +1,7 @@ -import subprocess +import os import pytest +import shutil +import subprocess from .repo import Repo from ..site import HAVE_GIT @@ -36,6 +38,14 @@ class Git(Repo): env=GIT_ENV, cwd=self.repo) return self.latest_commit() + def add_file(self, filename): + shutil.copy(filename, self.repo) + subprocess.call(['git', 'add', os.path.basename(filename)], env=GIT_ENV, cwd=self.repo) + subprocess.call([ + 'git', 'commit', '-m', 'Added {}'.format(os.path.basename(filename)) + ], env=GIT_ENV, cwd=self.repo) + return self.latest_commit() + def add_submodule(self, subdir, url=None, checkout=None): submodule = {} if checkout is not None: |