From 338cafc211e7a6c2f7317f725f8a979ca4e93368 Mon Sep 17 00:00:00 2001 From: bom Date: Thu, 2 Mar 2023 14:59:06 +0100 Subject: [PATCH] Validate correct branch in Release object Avoids throwing exceptions in service and delegates validation to the domain level --- services.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/services.py b/services.py index da3c6a5..741e3e1 100644 --- a/services.py +++ b/services.py @@ -8,12 +8,10 @@ class PrepareReleaseService(): self.release_repo = release_repo self.release = release_repo.get_release() self.git_api = GitApi() - self.main_branch = None def __write_and_commit_version(self, version: Version, commit_message: str): - if self.main_branch != self.git_api.get_current_branch(): - raise Exception('Trying to release while not on main branch') - + self.release.validate(self.release_repo.main_branch) + self.release_repo.version_repository.write_file(version.get_version_string()) self.git_api.add_file(self.release_repo.version_repository.file) self.git_api.commit(commit_message)