WIP implement patch

This commit is contained in:
bom 2023-02-08 11:52:15 +01:00
parent 09d08d6e43
commit c1928b8c44

View file

@ -5,7 +5,7 @@ def init_project():
# validate_values() # validate_values()
version = Version('package.json') version = Version('package.json')
version.parse() version.parse()
version.increment(ReleaseLevel.SNAPSHOT) version.increment(ReleaseLevel.PATCH)
print(version.get()) print(version.get())
def prepare_release(): def prepare_release():
@ -15,17 +15,17 @@ def release_in_git():
pass pass
class ReleaseLevel(Enum): class ReleaseLevel(Enum):
SNAPSHOT = 0 MAJOR = 0
PATCH = 1 MINOR = 1
MINOR = 2 PATCH = 2
MAJOR = 3 SNAPSHOT = 3
class Version(): class Version():
def __init__(self, config_file_path): def __init__(self, config_file_path):
self.version = "0.0.0" self.version = "0.0.0"
self.config_file_path = config_file_path self.config_file_path = config_file_path
print('init project')
def parse(self): def parse(self):
if self.config_file_path.split('.')[-1] == 'json': if self.config_file_path.split('.')[-1] == 'json':
@ -42,7 +42,10 @@ class Version():
if "-SNAPSHOT" not in self.version: if "-SNAPSHOT" not in self.version:
self.version = self.version + "-SNAPSHOT" self.version = self.version + "-SNAPSHOT"
case ReleaseLevel.PATCH: case ReleaseLevel.PATCH:
pass split_version = self.version.split('.')
patch_version = int(split_version[ReleaseLevel.PATCH.value])
self.version = split_version[:ReleaseLevel.PATCH.value] + str(patch_version + 1)
print(self.version)
case ReleaseLevel.MINOR: case ReleaseLevel.MINOR:
pass pass
case ReleaseLevel.MAJOR: case ReleaseLevel.MAJOR: