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"
MODULE = "not-used"
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"
description = __doc__
authors = [Author("meissa GmbH", "buero@meissa-gmbh.de")]

View file

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

View file

@ -69,38 +69,73 @@ class Version(Validateable):
new_version_list = self.version_list.copy()
if self.is_snapshot():
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:
new_version_list[2] += 1
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):
new_version_list = self.version_list.copy()
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:
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):
new_version_list = self.version_list.copy()
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:
new_version_list[2] = 0
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):
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, 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:
new_version_list[2] = 0
new_version_list[1] = 0
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,
)