This commit is contained in:
Michael Jerger 2023-07-12 08:19:31 +02:00
parent 0ef15f0102
commit 4e66aa24a5
3 changed files with 50 additions and 13 deletions

View file

@ -33,7 +33,7 @@ default_task = "dev"
name = "ddadevops" name = "ddadevops"
MODULE = "not-used" MODULE = "not-used"
PROJECT_ROOT_PATH = "." PROJECT_ROOT_PATH = "."
version = "4.0.10-SNAPSHOT" version = "4.0.10-dev1"
summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud" summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud"
description = __doc__ description = __doc__
authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")] authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")]

View file

@ -1,6 +1,7 @@
import json import json
import re import re
from enum import Enum from enum import Enum
from typing import Optional
from pathlib import Path from pathlib import Path
from .common import Validateable from .common import Validateable
from .version import Version from .version import Version
@ -26,9 +27,10 @@ class BuildFile(Validateable):
result += [f"Suffix {self.file_path} is unknown."] result += [f"Suffix {self.file_path} is unknown."]
return result return result
def build_file_type(self): def build_file_type(self) -> Optional[BuildFileType]:
result: Optional[BuildFileType] = None
if not self.file_path: if not self.file_path:
return None return result
config_file_type = self.file_path.suffix config_file_type = self.file_path.suffix
match config_file_type: match config_file_type:
case ".json": case ".json":
@ -115,7 +117,7 @@ class BuildFile(Validateable):
except: except:
raise Exception(f"Version not found in file {self.file_path}") raise Exception(f"Version not found in file {self.file_path}")
def get_default_suffix(self) -> Version: def get_default_suffix(self) -> str:
result = "SNAPSHOT" result = "SNAPSHOT"
match self.build_file_type(): match self.build_file_type():
case BuildFileType.PYTHON: case BuildFileType.PYTHON:

View file

@ -69,38 +69,73 @@ class Version(Validateable):
new_version_list = self.version_list.copy() new_version_list = self.version_list.copy()
if self.is_snapshot(): if self.is_snapshot():
return Version( return Version(
new_version_list, self.default_snapshot_suffix, snapshot_suffix=tmp_snapshot_suffix, version_str=None new_version_list,
self.default_snapshot_suffix,
snapshot_suffix=tmp_snapshot_suffix,
version_str=None,
) )
else: else:
new_version_list[2] += 1 new_version_list[2] += 1
return Version( return Version(
new_version_list, self.default_snapshot_suffix, snapshot_suffix=tmp_snapshot_suffix, version_str=None new_version_list,
self.default_snapshot_suffix,
snapshot_suffix=tmp_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():
return Version(new_version_list, self.default_snapshot_suffix, snapshot_suffix=None, version_str=None) return Version(
new_version_list,
self.default_snapshot_suffix,
snapshot_suffix=None,
version_str=None,
)
else: else:
new_version_list[2] += 1 new_version_list[2] += 1
return Version(new_version_list, self.default_snapshot_suffix, snapshot_suffix=None, version_str=None) return Version(
new_version_list,
self.default_snapshot_suffix,
snapshot_suffix=None,
version_str=None,
)
def create_minor(self): def create_minor(self):
new_version_list = self.version_list.copy() new_version_list = self.version_list.copy()
if self.is_snapshot() and new_version_list[2] == 0: if self.is_snapshot() and new_version_list[2] == 0:
return Version(new_version_list, self.default_snapshot_suffix, snapshot_suffix=None, version_str=None) return Version(
new_version_list,
self.default_snapshot_suffix,
snapshot_suffix=None,
version_str=None,
)
else: else:
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, self.default_snapshot_suffix, snapshot_suffix=None, version_str=None) return Version(
new_version_list,
self.default_snapshot_suffix,
snapshot_suffix=None,
version_str=None,
)
def create_major(self): def create_major(self):
new_version_list = self.version_list.copy() new_version_list = self.version_list.copy()
if self.is_snapshot() and new_version_list[2] == 0 and new_version_list[1] == 0: if self.is_snapshot() and new_version_list[2] == 0 and new_version_list[1] == 0:
return Version(new_version_list, self.default_snapshot_suffix, snapshot_suffix=None, version_str=None) return Version(
new_version_list,
self.default_snapshot_suffix,
snapshot_suffix=None,
version_str=None,
)
else: else:
new_version_list[2] = 0 new_version_list[2] = 0
new_version_list[1] = 0 new_version_list[1] = 0
new_version_list[0] += 1 new_version_list[0] += 1
return Version(new_version_list, self.default_snapshot_suffix, snapshot_suffix=None, version_str=None) return Version(
new_version_list,
self.default_snapshot_suffix,
snapshot_suffix=None,
version_str=None,
)