Compare commits

..

3 commits

Author SHA1 Message Date
bom
9c9676b5b8 Pass Release instead of Version object 2023-03-02 15:04:30 +01:00
bom
28344667db Remove unused fields from ReleaseMixin
These are handled through repos and services instead
2023-03-02 15:03:11 +01:00
bom
338cafc211 Validate correct branch in Release object
Avoids throwing exceptions in service and delegates validation to the
domain level
2023-03-02 14:59:06 +01:00
2 changed files with 6 additions and 15 deletions

View file

@ -31,20 +31,13 @@ class ReleaseMixin(DevopsBuild):
self.release_type_repo = ReleaseTypeRepository(self.git_api)
self.version_repo = VersionRepository(self.config_file)
self.release_repo = ReleaseRepository(self.version_repo, self.release_type_repo, self.main_branch)
self.release_version = None
self.bump_version = None
self.commit_string = None
def prepare_release(self):
prepare_release_service = PrepareReleaseService(self.release_repo)
if self.release_version is None or self.bump_version is None:
raise Exception('prepare_release was called before init_release')
# prepare_release_service.run_tests() # not implemented
prepare_release_service.write_and_commit_release()
prepare_release_service.write_and_commit_bump()
def tag_and_push_release(self):
tag_and_push_release_service = TagAndPushReleaseService(self.git_api)
tag_and_push_release_service.tag_and_push_release(self.release_version)
tag_and_push_release_service.tag_and_push_release(self.release_repo.get_release())

View file

@ -1,6 +1,6 @@
from pathlib import Path
from infrastructure import VersionRepository, ReleaseRepository, GitApi
from domain import Version, ReleaseType
from domain import Version, ReleaseType, Release
class PrepareReleaseService():
@ -8,11 +8,9 @@ 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)
@ -30,8 +28,8 @@ class TagAndPushReleaseService():
def __init__(self, git_api: GitApi):
self.git_api = git_api
def tag_and_push_release(self, release_version: Version):
annotation = 'v' + release_version.get_version_string()
def tag_and_push_release(self, release: Release):
annotation = 'v' + release.version.get_version_string()
message = 'Release ' + annotation
self.git_api.tag_annotated(annotation, message, 1)
# self.git_api.push()