diff --git a/src/pylorax/api/recipes.py b/src/pylorax/api/recipes.py index 65885f90..87429ea7 100644 --- a/src/pylorax/api/recipes.py +++ b/src/pylorax/api/recipes.py @@ -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 diff --git a/tests/pylorax/test_recipes.py b/tests/pylorax/test_recipes.py index fc935763..6f1b2277 100644 --- a/tests/pylorax/test_recipes.py +++ b/tests/pylorax/test_recipes.py @@ -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")