From c13734493296543ff07709a94e5068fc9103b875 Mon Sep 17 00:00:00 2001 From: erik Date: Mon, 20 Feb 2023 16:21:02 +0100 Subject: [PATCH] Implement bump release --- services.py | 2 +- version.py | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/services.py b/services.py index c7240aa..952dc2d 100644 --- a/services.py +++ b/services.py @@ -31,7 +31,7 @@ class InitReleaseService(): raise Exception('VersionRepo was not created. Did you run create_lease_version()?') version_list = self.get_version_list() - bump_version = Version.create_bump_version(version_list, ReleaseType.SNAPSHOT) + bump_version = Version.create_bump_version(version_list) self.version_repo.write_file(bump_version.get_version_string()) diff --git a/version.py b/version.py index 162e28c..863f82e 100644 --- a/version.py +++ b/version.py @@ -3,7 +3,7 @@ from file_handlers import FileHandler def init_project(): # validate_values() - version = Version.from_file('build.gradle') + version = Version.from_file('build.gradle') version.increment(ReleaseType.SNAPSHOT) version.to_file() print(version.get()) @@ -19,6 +19,7 @@ class ReleaseType(Enum): MINOR = 1 PATCH = 2 SNAPSHOT = 3 + BUMP = None class Version(): @@ -30,6 +31,9 @@ class Version(): def increment(self, release_type: ReleaseType): self.is_snapshot = False match release_type: + case ReleaseType.BUMP: + self.is_snapshot = True + self.version_list[ReleaseType.PATCH.value] += 1 case ReleaseType.SNAPSHOT: self.is_snapshot = True case ReleaseType.PATCH: @@ -45,16 +49,19 @@ class Version(): def get_version_string(self) -> str: self.version_string = ".".join([str(x) for x in self.version_list]) if self.is_snapshot: - self.version_string += "-SNAPSHOT" + self.version_string += "-SNAPSHOT" @classmethod def create_release_version(cls, version_list, release_type): inst = cls(version_list, release_type) - inst.increment(release_type) - + if release_type == ReleaseType.PATCH: + inst.is_snapshot = False + else: + inst.increment(release_type) return inst - @classmethod - def create_bump_version(cls, version_list, release_type): - pass \ No newline at end of file + def create_bump_version(cls, version_list): + inst = cls(version_list, ReleaseType.BUMP) + inst.increment(release_type) + return inst