Add revert_recipe function
And adjust the tests to use it so that it covers both revert_recipe and revert_file.
This commit is contained in:
parent
c294b7747d
commit
ab6decec0b
@ -379,6 +379,23 @@ def delete_file(repo, branch, filename):
|
||||
message = "Recipe %s deleted" % filename
|
||||
return repo.create_commit(ref, sig, sig, "UTF-8", message, tree, [parent_commit])
|
||||
|
||||
def revert_recipe(repo, branch, recipe_name, commit):
|
||||
"""Revert the contents of a recipe to that of a previous commit
|
||||
|
||||
:param repo: Open repository
|
||||
:type repo: Git.Repository
|
||||
:param branch: Branch name
|
||||
:type branch: str
|
||||
:param recipe_name: Recipe name to revert
|
||||
:type recipe_name: str
|
||||
:param commit: Commit hash
|
||||
:type commit: str
|
||||
:returns: OId of the new commit
|
||||
:rtype: Git.OId
|
||||
:raises: Can raise errors from Ggit
|
||||
"""
|
||||
return revert_file(repo, branch, recipe_filename(recipe_name), commit)
|
||||
|
||||
def revert_file(repo, branch, filename, commit):
|
||||
"""Revert the contents of a file to that of a previous commit
|
||||
|
||||
|
@ -184,7 +184,7 @@ class GitRecipesTest(unittest.TestCase):
|
||||
"""Test reverting a file on a branch"""
|
||||
commits = recipes.list_commits(self.repo, "master", "http-server.toml")
|
||||
revert_to = commits[0].commit
|
||||
oid = recipes.revert_file(self.repo, "master", "http-server.toml", revert_to)
|
||||
oid = recipes.revert_recipe(self.repo, "master", "http-server", revert_to)
|
||||
self.assertNotEqual(oid, None)
|
||||
|
||||
commits = recipes.list_commits(self.repo, "master", "http-server.toml")
|
||||
|
Loading…
Reference in New Issue
Block a user