add some version funct.

This commit is contained in:
Michael Jerger 2023-05-10 09:28:43 +02:00
parent 9ae6679bfd
commit d38c2baaa1
3 changed files with 49 additions and 39 deletions

View file

@ -37,25 +37,29 @@ classDiagram
release_main_branch release_main_branch
release_current_branch release_current_branch
release_type release_type
version
} }
class BuildFile { class BuildFile {
filename <<AggregateRoot>>
file_path [id]
file_type file_type
content content
} }
class Version { class Version {
get_version_string(release_type: ReleaseType) get_version_string()
create_release_version(release_type: ReleaseType): create_major()
create_bump_version(release_type: ReleaseType): create_minor()
create_patchn()
create_bump()
} }
Devops *-- "0..1" Image: spcialized_builds Devops *-- "0..1" Image: spcialized_builds
Devops *-- "0..1" C4k: spcialized_builds Devops *-- "0..1" C4k: spcialized_builds
Devops *-- "0..1" Release: mixins Devops *-- "0..1" Release: mixins
Release *-- "0..1" BuildFile: primary_release_file Release o-- "0..1" BuildFile: primary_release_file
Release *-- "0..n" BuildFile: secondary_release_files Release o-- "0..n" BuildFile: secondary_release_files
BuildFile *-- "1" Version BuildFile *-- "1" Version
C4k *-- DnsRecord C4k *-- DnsRecord

View file

@ -48,17 +48,21 @@ class Version(Validateable):
result += [f"version_list must have at least 3 levels."] result += [f"version_list must have at least 3 levels."]
if self.version_list and self.version_string and self.to_string() != self.version_string: if self.version_list and self.version_string and self.to_string() != self.version_string:
result += [f"version_string not parsed correct. Input was {self.version_string} parsed was {self.to_string()}"] result += [f"version_string not parsed correct. Input was {self.version_string} parsed was {self.to_string()}"]
return result return result
# def create_release_version(self, release_type: ReleaseType | None): def create_patch(self):
# release_version = Version(self.path, self.version_list.copy()) new_version_list = self.version_list.copy()
# release_version.is_snapshot = self.is_snapshot if self.is_snapshot():
# release_version.increment(release_type) return Version(new_version_list, snapshot_suffix=None, version_str=None)
# return release_version else:
new_version_list[2] += 1
return Version(new_version_list, snapshot_suffix=None, version_str=None)
# def create_bump_version(self): def create_minor(self):
# bump_version = Version(self.path, self.version_list.copy()) new_version_list = self.version_list.copy()
# bump_version.is_snapshot = self.is_snapshot if self.is_snapshot() and new_version_list[2] == 0:
# bump_version.increment(ReleaseType.BUMP) return Version(new_version_list, snapshot_suffix=None, version_str=None)
# return bump_version else:
new_version_list[2] = 0
new_version_list[1] += 1
return Version(new_version_list, snapshot_suffix=None, version_str=None)

View file

@ -52,28 +52,30 @@ def test_should_validate_parsing():
assert sut.is_valid() assert sut.is_valid()
def test_version(): def test_should_create_patch():
pass version = Version.from_str("1.2.3-SNAPSHOT")
# version = Version.version_from_str("1.2.3-SNAPSHOT") sut = version.create_patch()
# version.increment(ReleaseType.NONE) assert sut.to_string() == "1.2.3"
# assert version.get_version_string() == "1.2.3-SNAPSHOT" assert version.to_string() == "1.2.3-SNAPSHOT"
# assert version.version_list == [1, 2, 3]
# assert version.is_snapshot
# version = Version.version_from_str("1.2.3") version = Version.from_str("1.2.3")
# version.increment(ReleaseType.PATCH) sut = version.create_patch()
# assert version.get_version_string() == "1.2.4" assert sut.to_string() == "1.2.4"
# assert version.version_list == [1, 2, 4] assert version.to_string() == "1.2.3"
# assert not version.is_snapshot
# version = Version.version_from_str("1.2.3") def test_should_create_minor():
# version.increment(ReleaseType.MINOR) version = Version.from_str("1.2.3-SNAPSHOT")
# assert version.get_version_string() == "1.3.0" sut = version.create_minor()
# assert version.version_list == [1, 3, 0] assert sut.to_string() == "1.3.0"
# assert not version.is_snapshot
# version = Version.version_from_str("1.2.3") version = Version.from_str("1.2.3")
# version.increment(ReleaseType.MAJOR) sut = version.create_minor()
# assert version.get_version_string() == "2.0.0" assert sut.to_string() == "1.3.0"
# assert version.version_list == [2, 0, 0]
# assert not version.is_snapshot version = Version.from_str("1.3.0-SNAPSHOT")
sut = version.create_minor()
assert sut.to_string() == "1.3.0"
version = Version.from_str("1.3.0")
sut = version.create_minor()
assert sut.to_string() == "1.4.0"