Validate correct branch in Release object

Avoids throwing exceptions in service and delegates validation to the
domain level
This commit is contained in:
bom 2023-03-02 14:59:06 +01:00
parent 9bde301ee4
commit 338cafc211

View file

@ -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)