finish version
This commit is contained in:
parent
d38c2baaa1
commit
2e2c04c8ba
3 changed files with 53 additions and 3 deletions
|
@ -51,8 +51,8 @@ classDiagram
|
||||||
get_version_string()
|
get_version_string()
|
||||||
create_major()
|
create_major()
|
||||||
create_minor()
|
create_minor()
|
||||||
create_patchn()
|
create_patch()
|
||||||
create_bump()
|
create_bump(snapshot_suffix)
|
||||||
}
|
}
|
||||||
|
|
||||||
Devops *-- "0..1" Image: spcialized_builds
|
Devops *-- "0..1" Image: spcialized_builds
|
||||||
|
|
|
@ -50,6 +50,15 @@ class Version(Validateable):
|
||||||
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_bump(self, snapshot_suffix: str = None):
|
||||||
|
new_version_list = self.version_list.copy()
|
||||||
|
if self.is_snapshot():
|
||||||
|
return Version(new_version_list, snapshot_suffix=self.snapshot_suffix, version_str=None)
|
||||||
|
else:
|
||||||
|
new_version_list[2] = 0
|
||||||
|
new_version_list[1] += 1
|
||||||
|
return Version(new_version_list, snapshot_suffix=snapshot_suffix, version_str=None)
|
||||||
|
|
||||||
def create_patch(self):
|
def create_patch(self):
|
||||||
new_version_list = self.version_list.copy()
|
new_version_list = self.version_list.copy()
|
||||||
if self.is_snapshot():
|
if self.is_snapshot():
|
||||||
|
@ -66,3 +75,13 @@ class Version(Validateable):
|
||||||
new_version_list[2] = 0
|
new_version_list[2] = 0
|
||||||
new_version_list[1] += 1
|
new_version_list[1] += 1
|
||||||
return Version(new_version_list, snapshot_suffix=None, version_str=None)
|
return Version(new_version_list, snapshot_suffix=None, version_str=None)
|
||||||
|
|
||||||
|
def create_major(self):
|
||||||
|
new_version_list = self.version_list.copy()
|
||||||
|
if self.is_snapshot() and new_version_list[2] == 0 and new_version_list[1] == 0 :
|
||||||
|
return Version(new_version_list, snapshot_suffix=None, version_str=None)
|
||||||
|
else:
|
||||||
|
new_version_list[2] = 0
|
||||||
|
new_version_list[1] = 0
|
||||||
|
new_version_list[0] += 1
|
||||||
|
return Version(new_version_list, snapshot_suffix=None, version_str=None)
|
||||||
|
|
|
@ -79,3 +79,34 @@ def test_should_create_minor():
|
||||||
version = Version.from_str("1.3.0")
|
version = Version.from_str("1.3.0")
|
||||||
sut = version.create_minor()
|
sut = version.create_minor()
|
||||||
assert sut.to_string() == "1.4.0"
|
assert sut.to_string() == "1.4.0"
|
||||||
|
|
||||||
|
|
||||||
|
def test_should_create_major():
|
||||||
|
version = Version.from_str("1.2.3-SNAPSHOT")
|
||||||
|
sut = version.create_major()
|
||||||
|
assert sut.to_string() == "2.0.0"
|
||||||
|
|
||||||
|
version = Version.from_str("1.2.3")
|
||||||
|
sut = version.create_major()
|
||||||
|
assert sut.to_string() == "2.0.0"
|
||||||
|
|
||||||
|
version = Version.from_str("1.0.0-SNAPSHOT")
|
||||||
|
sut = version.create_major()
|
||||||
|
assert sut.to_string() == "1.0.0"
|
||||||
|
|
||||||
|
version = Version.from_str("1.0.0")
|
||||||
|
sut = version.create_major()
|
||||||
|
assert sut.to_string() == "2.0.0"
|
||||||
|
|
||||||
|
def test_should_create_bump():
|
||||||
|
version = Version.from_str("1.2.3-SNAPSHOT")
|
||||||
|
sut = version.create_bump()
|
||||||
|
assert sut.to_string() == "1.2.3-SNAPSHOT"
|
||||||
|
|
||||||
|
version = Version.from_str("1.2.3")
|
||||||
|
sut = version.create_bump("SNAPSHOT")
|
||||||
|
assert sut.to_string() == "1.3.0-SNAPSHOT"
|
||||||
|
|
||||||
|
version = Version.from_str("1.0.0")
|
||||||
|
sut = version.create_bump("SNAPSHOT")
|
||||||
|
assert sut.to_string() == "1.1.0-SNAPSHOT"
|
Loading…
Reference in a new issue