diff --git a/version.py b/domain.py similarity index 75% rename from version.py rename to domain.py index 3cfca62..c5193a6 100644 --- a/version.py +++ b/domain.py @@ -1,5 +1,12 @@ -from release_type import ReleaseType -from file_handlers import FileHandler +from enum import Enum + +class ReleaseType(Enum): + MAJOR = 0 + MINOR = 1 + PATCH = 2 + SNAPSHOT = 3 + BUMP = None + class Version(): @@ -19,11 +26,11 @@ class Version(): case ReleaseType.PATCH: self.version_list[ReleaseType.PATCH.value] += 1 case ReleaseType.MINOR: - self.version_list[ReleaseType.PATCH.value] = 0 + self.version_list[ReleaseType.PATCH.value] = 0 self.version_list[ReleaseType.MINOR.value] += 1 case ReleaseType.MAJOR: - self.version_list[ReleaseType.PATCH.value] = 0 - self.version_list[ReleaseType.MINOR.value] = 0 + self.version_list[ReleaseType.PATCH.value] = 0 + self.version_list[ReleaseType.MINOR.value] = 0 self.version_list[ReleaseType.MAJOR.value] += 1 case None: raise Exception("Release Type was not set!") @@ -33,15 +40,21 @@ class Version(): if self.is_snapshot: self.version_string += "-SNAPSHOT" return self.version_string - + def create_release_version(self, release_type: ReleaseType): release_version = Version(self.version_list.copy()) release_version.is_snapshot = self.is_snapshot release_version.increment(release_type) - return release_version - + return release_version + def create_bump_version(self): bump_version = Version(self.version_list.copy()) bump_version.is_snapshot = self.is_snapshot bump_version.increment(ReleaseType.BUMP) return bump_version + + +class Release(): + def __init__(self, release_type: ReleaseType, version: Version): + self.release_type = release_type + self.version = version diff --git a/git_repository.py b/git_repository.py index e835384..5761048 100644 --- a/git_repository.py +++ b/git_repository.py @@ -2,7 +2,7 @@ import os import subprocess as sub from pathlib import Path from system_repository import SystemRepository -from release_type import ReleaseType +from domain import ReleaseType class GitRepository(): diff --git a/infrastructure.py b/infrastructure.py new file mode 100644 index 0000000..baa9e74 --- /dev/null +++ b/infrastructure.py @@ -0,0 +1,8 @@ +from domain import Release + +class ReleaseRepository(): + def __init__(self): + pass + + def get_current_release(self) -> Release: + pass \ No newline at end of file diff --git a/release_mixin.py b/release_mixin.py index 13b174a..7e02598 100644 --- a/release_mixin.py +++ b/release_mixin.py @@ -2,11 +2,10 @@ import copy from ddadevops import DevopsBuild from ddadevops import execute from ddadevops import gopass_field_from_path, gopass_password_from_path -from version import Version from version_repository import VersionRepository from services import InitReleaseService, PrepareReleaseService, TagAndPushReleaseService from git_repository import GitRepository -from release_type import ReleaseType +from domain import ReleaseType, Version def create_release_mixin_config(config_file, main_branch) -> dict: config = {} diff --git a/release_type.py b/release_type.py deleted file mode 100644 index e4217a5..0000000 --- a/release_type.py +++ /dev/null @@ -1,7 +0,0 @@ -from enum import Enum -class ReleaseType(Enum): - MAJOR = 0 - MINOR = 1 - PATCH = 2 - SNAPSHOT = 3 - BUMP = None \ No newline at end of file diff --git a/services.py b/services.py index 3ff28de..5453bee 100644 --- a/services.py +++ b/services.py @@ -2,7 +2,7 @@ from pathlib import Path from version_repository import VersionRepository from release_type import ReleaseType from git_repository import GitRepository -from version import Version +from domain import Version class InitReleaseService(): diff --git a/version_repository.py b/version_repository.py index 2c3ec63..16e706f 100644 --- a/version_repository.py +++ b/version_repository.py @@ -1,5 +1,5 @@ from file_handlers import FileHandler -from version import Version +from domain import Version class VersionRepository():