Compare commits
4 commits
99b8884d11
...
2fe05b0e06
Author | SHA1 | Date | |
---|---|---|---|
2fe05b0e06 | |||
fa73c52fe2 | |||
c91bbe787b | |||
d759036989 |
4 changed files with 25 additions and 9 deletions
|
@ -17,8 +17,8 @@ class GitRepository():
|
|||
return inst
|
||||
|
||||
def get_latest_commit(self):
|
||||
self.system_repository.run_checked('git', 'log', '--oneline', '--format="%s %b"', '-n' + '1')
|
||||
self.latest_commit = self.system_repository.stdout
|
||||
self.system_repository.run_checked('git', 'log', '--oneline', '--format="%s %b"', '-n 1')
|
||||
self.latest_commit = " ".join(self.system_repository.stdout) # returns a list of strings otherwise
|
||||
|
||||
def get_release_type_from_latest_commit(self):
|
||||
if self.latest_commit is None:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import copy
|
||||
from ddadevops import DevopsBuild
|
||||
from ddadevops import execute
|
||||
from ddadevops import gopass_field_from_path, gopass_password_from_path
|
||||
|
@ -31,11 +32,13 @@ class ReleaseMixin(DevopsBuild):
|
|||
self.version_repo = VersionRepository(self.file)
|
||||
self.release_version = None
|
||||
self.bump_version = None
|
||||
self.commit_string = None
|
||||
|
||||
def init(self):
|
||||
init_service = InitReleaseService(self.version_repo)
|
||||
self.release_version = init_service.create_release_version()
|
||||
self.bump_version = self.release_version.create_bump_version()
|
||||
self.release_version = init_service.create_release_version(self.commit_string)
|
||||
release_version_copy = copy.deepcopy(self.release_version) # otherwise we'll modify the release_version again
|
||||
self.bump_version = release_version_copy.create_bump_version()
|
||||
|
||||
def prepare(self, version):
|
||||
git_repository = GitRepository()
|
||||
|
|
|
@ -6,7 +6,7 @@ class SystemRepository():
|
|||
self.stdout = [""]
|
||||
self.stderr = [""]
|
||||
|
||||
def run(self, *args):
|
||||
def run(self, args):
|
||||
stream = sub.Popen(args,
|
||||
stdout=sub.PIPE,
|
||||
stderr=sub.PIPE,
|
||||
|
|
|
@ -23,7 +23,10 @@ from version import *
|
|||
from release_mixin import ReleaseMixin, create_release_mixin_config
|
||||
|
||||
MAIN_BRANCH = 'main'
|
||||
|
||||
STAGE = 'test'
|
||||
PROJECT_ROOT_PATH = '.'
|
||||
MODULE = 'test'
|
||||
BUILD_DIR_NAME = "build_dir"
|
||||
|
||||
class MyBuild(ReleaseMixin):
|
||||
pass
|
||||
|
@ -31,11 +34,16 @@ class MyBuild(ReleaseMixin):
|
|||
def initialize(project, CONFIG_FILE):
|
||||
project.build_depends_on('ddadevops>=3.1.2')
|
||||
config = create_release_mixin_config(CONFIG_FILE, MAIN_BRANCH)
|
||||
config.update({'stage': STAGE})
|
||||
config.update({'module': MODULE})
|
||||
config.update({'project_root_path': PROJECT_ROOT_PATH})
|
||||
config.update({'build_dir_name': BUILD_DIR_NAME})
|
||||
build = MyBuild(project, config)
|
||||
return build
|
||||
|
||||
def test_release_mixin(tmp_path):
|
||||
|
||||
#init
|
||||
with open(f'test/resources/config.json', 'r') as json_file:
|
||||
contents = json_file.read()
|
||||
|
||||
|
@ -46,11 +54,16 @@ def test_release_mixin(tmp_path):
|
|||
project = Project(base_dir)
|
||||
|
||||
# init
|
||||
build = initialize(project, CONFIG_FILE)
|
||||
build = initialize(project, CONFIG_FILE)
|
||||
build.commit_string = "MAJOR bla"
|
||||
build.init()
|
||||
release_version = build.release_version
|
||||
|
||||
# test
|
||||
assert "124.0.0" in release_version.get_version_string()
|
||||
|
||||
# init
|
||||
bump_version = build.bump_version
|
||||
|
||||
# test
|
||||
assert "123.124.0" in release_version.get_version_string()
|
||||
assert "123.124.1-SNAPSHOT" in bump_version.get_version_string()
|
||||
assert "124.0.1-SNAPSHOT" in bump_version.get_version_string()
|
Loading…
Reference in a new issue