From 7f1adf120c543c558224406a5320863c057f08da Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 13 Nov 2017 16:16:57 -0800 Subject: [PATCH] Add tag_recipe_commit helper function And change tests to use it so that both it and tag_file_commit are used. --- src/pylorax/api/recipes.py | 17 +++++++++++++++++ tests/pylorax/test_recipes.py | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/pylorax/api/recipes.py b/src/pylorax/api/recipes.py index 485833d1..2fce5a1b 100644 --- a/src/pylorax/api/recipes.py +++ b/src/pylorax/api/recipes.py @@ -498,6 +498,23 @@ def commit_recipe_directory(repo, branch, directory): except (RecipeFileError, toml.TomlError): pass +def tag_recipe_commit(repo, branch, recipe_name): + """Tag a file's most recent commit + + :param repo: Open repository + :type repo: Git.Repository + :param branch: Branch name + :type branch: str + :param recipe_name: Recipe name to tag + :type recipe_name: str + :returns: Tag id or None if it failed. + :rtype: Git.OId + :raises: Can raise errors from Ggit + + Uses tag_file_commit() + """ + return tag_file_commit(repo, branch, recipe_filename(recipe_name)) + def tag_file_commit(repo, branch, filename): """Tag a file's most recent commit diff --git a/tests/pylorax/test_recipes.py b/tests/pylorax/test_recipes.py index 37f76a79..d88abd3e 100644 --- a/tests/pylorax/test_recipes.py +++ b/tests/pylorax/test_recipes.py @@ -165,7 +165,7 @@ class GitRecipesTest(unittest.TestCase): result = recipes.tag_file_commit(self.repo, "master", "not-a-file") self.assertEqual(result, None) - result = recipes.tag_file_commit(self.repo, "master", "http-server.toml") + result = recipes.tag_recipe_commit(self.repo, "master", "http-server") self.assertNotEqual(result, None) commits = recipes.list_commits(self.repo, "master", "http-server.toml") @@ -199,7 +199,7 @@ class GitRecipesTest(unittest.TestCase): self.assertNotEqual(oid, None) # Tag the new commit - result = recipes.tag_file_commit(self.repo, "master", "http-server.toml") + result = recipes.tag_recipe_commit(self.repo, "master", "http-server") self.assertNotEqual(result, None) commits = recipes.list_commits(self.repo, "master", "http-server.toml")