2023-02-22 08:59:16 +00:00
|
|
|
from version_repository import VersionRepository
|
|
|
|
from release_type import ReleaseType
|
2023-02-22 09:27:07 +00:00
|
|
|
from git_repository import GitRepository
|
2023-02-22 08:59:16 +00:00
|
|
|
|
2023-02-16 15:55:01 +00:00
|
|
|
class InitReleaseService():
|
|
|
|
|
|
|
|
def __init__(self, commit_id, file):
|
|
|
|
self.commit_id = commit_id
|
|
|
|
self.file = file
|
2023-02-22 09:27:07 +00:00
|
|
|
self.version_repo = None
|
2023-02-16 15:55:01 +00:00
|
|
|
|
|
|
|
def __calculate_release_type(self):
|
2023-02-22 09:27:07 +00:00
|
|
|
return GitRepository().get_release_type_from_latest_commit()
|
|
|
|
|
2023-02-21 14:52:09 +00:00
|
|
|
def get_version(self, release_type):
|
|
|
|
self.version_repo = VersionRepository(self.file)
|
2023-02-22 08:59:16 +00:00
|
|
|
return self.version_repo.get_version(release_type)
|
2023-02-20 13:45:15 +00:00
|
|
|
|
|
|
|
def create_release_version(self):
|
2023-02-16 15:55:01 +00:00
|
|
|
commit_message = self.read_commit_message(self.commit_id)
|
2023-02-22 09:27:07 +00:00
|
|
|
release_type = self.__calculate_release_type(commit_message)
|
2023-02-21 14:52:09 +00:00
|
|
|
version = self.get_version(release_type).create_release_version()
|
|
|
|
|
|
|
|
self.version_repo.write_file(version.get_version_string())
|
2023-02-16 15:55:01 +00:00
|
|
|
|
|
|
|
def create_bump_version(self):
|
2023-02-20 14:50:58 +00:00
|
|
|
if self.version_repo == None:
|
|
|
|
raise Exception('VersionRepo was not created. Did you run create_lease_version()?')
|
2023-02-21 14:52:09 +00:00
|
|
|
version = self.get_version(ReleaseType.BUMP).create_bump_version()
|
|
|
|
|
|
|
|
self.version_repo.write_file(version.get_version_string())
|
2023-02-20 14:50:58 +00:00
|
|
|
|
2023-02-16 15:55:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PrepareReleaseService():
|
|
|
|
pass
|
|
|
|
|
|
|
|
class TagAndPushReleaseService():
|
|
|
|
pass
|
|
|
|
|