From 4a23b0b800c61ec764f1fa9492e5b5b9879a0bef Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 23 Feb 2023 15:33:34 +0100 Subject: [PATCH] Implement and use TagAndPushReleaseService --- release_mixin.py | 16 +++------------- services.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/release_mixin.py b/release_mixin.py index b31e838..44adc92 100644 --- a/release_mixin.py +++ b/release_mixin.py @@ -49,16 +49,6 @@ class ReleaseMixin(DevopsBuild): prepare_release_service.write_and_commit_release(self.release_version) prepare_release_service.write_and_commit_bump(self.bump_version) - def tag_and_push(self, version): - git_repository = GitRepository() - match version.release_type: - case None: - raise Exception('Release type not set but trying to tag and push.') - case ReleaseType.BUMP: - annotation = 'v' + version.get_version_string() - message = 'Version bump' - case _: - annotation = 'v' + self.release_version.get_version_string() - message = 'Release' + annotation - git_repository.tag_annotated(annotation, message) - git_repository.push() + def tag_and_push(self): + tag_and_push_release_service = TagAndPushReleaseService(self.git_repo) + tag_and_push_release_service.tag_and_push_release(self.release_version) diff --git a/services.py b/services.py index 04eac74..0751046 100644 --- a/services.py +++ b/services.py @@ -56,5 +56,14 @@ class PrepareReleaseService(): self.__write_and_commit_version(bump_version, commit_message=f'Version bump') class TagAndPushReleaseService(): - pass + + def __init__(self, git_repository: GitRepository): + self.git_repository = git_repository + + def tag_and_push_release(self, release_version: Version): + annotation = 'v' + release_version.get_version_string() + message = 'Release ' + annotation + self.git_repository.tag_annotated(annotation, message, 1) + self.git_repository.push() +