SNAPSHOT for pybuild_files

This commit is contained in:
Mirco 2023-07-07 15:11:21 +02:00
parent 34527621ac
commit 03bf8e5dea
3 changed files with 24 additions and 3 deletions

View file

@ -61,7 +61,7 @@ class BuildFile(Validateable):
version_line = re.search("\nversion = .*\n", self.content)
version_line_group = version_line.group()
version_string = re.search(
"[0-9]*\\.[0-9]*\\.[0-9]*(-dev)?[0-9]*", version_line_group
"[0-9]*\\.[0-9]*\\.[0-9]*(-SNAPSHOT)?(-dev)?[0-9]*", version_line_group
)
version_str = version_string.group()
case BuildFileType.JAVA_CLOJURE:
@ -97,7 +97,7 @@ class BuildFile(Validateable):
self.content = substitute
case BuildFileType.PYTHON:
substitute = re.sub(
'\nversion = "[0-9]*\\.[0-9]*\\.[0-9]*(-dev)?[0-9]*"',
'\nversion = "[0-9]*\\.[0-9]*\\.[0-9]*(-SNAPSHOT)?(-dev)?[0-9]*"',
f'\nversion = "{new_version.to_string()}"',
self.content,
)

View file

@ -116,6 +116,27 @@ version = "1.1.5-dev12"
sut.set_version(Version.from_str("1.1.5-dev12").create_major())
assert '\nversion = "2.0.0"\n' == sut.content
sut = BuildFile(
Path("./build.py"),
"""
from pybuilder.core import init, use_plugin, Author
use_plugin("python.core")
name = "ddadevops"
version = "1.1.5-SNAPSHOT"
summary = "tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud"
""",
)
assert sut.get_version() == Version.from_str("1.1.5-SNAPSHOT")
sut = BuildFile(
Path("./build.py"),
"""
version = "1.1.5-SNAPSHOT"
""",
)
sut.set_version(Version.from_str("1.1.5-SNAPSHOT").create_major())
assert '\nversion = "2.0.0"\n' == sut.content
def test_sould_parse_and_set_version_for_clj():
sut = BuildFile(

View file

@ -48,7 +48,7 @@ def test_sould_validate_release():
assert not sut.is_valid()
def test_sould_validate_release():
def test_sould_calculate_build_files():
sut = Release(
devops_config(
{