summaryrefslogtreecommitdiff
path: root/tests/testutils
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-09-14 18:46:27 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-09-14 21:07:46 +0900
commitce68fd2755db2cad98a9498efb289f9a7d8899d3 (patch)
treea9eb350ebdedaac3fe45394455f626c8dc56efa2 /tests/testutils
parentf60558a328e1803d385756f2f6e24bf385e79041 (diff)
downloadbuildstream-ce68fd2755db2cad98a9498efb289f9a7d8899d3.tar.gz
testutils/repo/git.py: Added modify_file() method
This allows one to modify a file in an existing git repo, as opposed to adding a new one.
Diffstat (limited to 'tests/testutils')
-rw-r--r--tests/testutils/repo/git.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/testutils/repo/git.py b/tests/testutils/repo/git.py
index 8c2a8c177..c598eb4d0 100644
--- a/tests/testutils/repo/git.py
+++ b/tests/testutils/repo/git.py
@@ -52,6 +52,13 @@ class Git(Repo):
self._run_git('commit', '-m', 'Added {}'.format(os.path.basename(filename)))
return self.latest_commit()
+ def modify_file(self, new_file, path):
+ shutil.copy(new_file, os.path.join(self.repo, path))
+ subprocess.call([
+ 'git', 'commit', path, '-m', 'Modified {}'.format(os.path.basename(path))
+ ], 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: