Validate correct branch in Release object

Avoids throwing exceptions in service and delegates validation to the
domain level
main
bom 1 year ago
parent 9bde301ee4
commit 338cafc211

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

Loading…
Cancel
Save