59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
from version_repository import VersionRepository
|
|
from release_type import ReleaseType
|
|
from git_repository import GitRepository
|
|
from version import Version
|
|
|
|
class InitReleaseService():
|
|
|
|
def __init__(self, version_repo: VersionRepository):
|
|
if version_repo is None:
|
|
raise Exception('VersionRepo was not created. Did you run create_release_version()?')
|
|
self.version_repo = version_repo
|
|
|
|
def __calculate_release_type(self, commit_string = None):
|
|
if commit_string is None:
|
|
return GitRepository().get_release_type_from_latest_commit()
|
|
else:
|
|
return GitRepository.create_from_commit_string(commit_string).get_release_type_from_latest_commit()
|
|
|
|
def get_version(self):
|
|
return self.version_repo.get_version()
|
|
|
|
def create_release_version(self, commit_string = None):
|
|
release_type = self.__calculate_release_type(commit_string)
|
|
version = self.get_version().create_release_version(release_type)
|
|
return version
|
|
|
|
def create_bump_version(self):
|
|
version = self.get_version().create_bump_version()
|
|
return version
|
|
|
|
|
|
class PrepareReleaseService():
|
|
|
|
def __init__(self, version_repo: VersionRepository):
|
|
self.version_repo = version_repo
|
|
|
|
|
|
def run_tests(self): # maybe auto?
|
|
pass
|
|
|
|
def prepare_release(self, version: Version):
|
|
# self.version_repo.write_file(version.get_version_string()) # side effect
|
|
pass
|
|
|
|
def prepare_bump(self, version: Version):
|
|
# self.version_repo.write_file(version.get_version_string()) # side effect
|
|
pass
|
|
|
|
|
|
# write
|
|
|
|
|
|
# add
|
|
# commit
|
|
pass
|
|
|
|
class TagAndPushReleaseService():
|
|
pass
|
|
|