Compare commits

..

No commits in common. "238b0304b66336ce7f052d7163f08551b8eacf4c" and "1112b1ad4902f098feefb8c90221276ced8efacb" have entirely different histories.

3 changed files with 12 additions and 42 deletions

View file

@ -1,6 +1,5 @@
import os import os
import subprocess as sub import subprocess as sub
from pathlib import Path
from system_repository import SystemRepository from system_repository import SystemRepository
from release_type import ReleaseType from release_type import ReleaseType
@ -34,18 +33,3 @@ class GitRepository():
else: else:
return None return None
def get_current_branch(self):
self.system_repository.run_checked('git', 'branch', '--show-current')
def add_file(self, file_path: Path):
self.system_repository.run_checked('git', 'add', file_path)
def commit(self, commit_message: str):
self.system_repository.run_checked('git', 'commit', '-m', commit_message)
def push(self):
self.system_repository.run_checked('git', 'push')
def checkout(self, branch: str):
self.system_repository.run_checked('git', 'checkout', branch)

View file

@ -1,15 +1,15 @@
from ddadevops import DevopsBuild from ddadevops import DevopsBuild
from ddadevops import execute from ddadevops import execute
from ddadevops import gopass_field_from_path, gopass_password_from_path from ddadevops import gopass_field_from_path, gopass_password_from_path
from version import Version from version import Version
from version_repository import VersionRepository from version_repository import VersionRepository
from services import InitReleaseService, PrepareReleaseService, TagAndPushReleaseService
from git_repository import GitRepository
def create_release_mixin_config(config, release_type, config_file, main_branch):
config.update({'ReleaseMixin': def create_release_mixin_config(config, release_type, commit, file):
{'main_branch': main_branch, config.update({'ReleaseMixin':
'file': config_file}}) {'commit_id': commit,
'file': file}})
return config return config
@ -19,28 +19,14 @@ class ReleaseMixin(DevopsBuild):
super().__init__(project, config) super().__init__(project, config)
release_mixin_config = config['ReleaseMixin'] release_mixin_config = config['ReleaseMixin']
self.file = release_mixin_config['file'] self.file = release_mixin_config['file']
self.main_branch = release_mixin_config['main_branch']
self.version_repo = VersionRepository(self.file) self.version_repo = VersionRepository(self.file)
def init(self): # returns versions def init(self): # returns versions
init_service = InitReleaseService(self.version_repo) release_and_bump_version = InitReleaseService(self.version_repo).get_version()
release_version = init_service.create_release_version() return release_and_bump_version
bump_version = release_version.create_bump_version()
return release_version, bump_version
def prepare(self, release_version: Version, bump_version: Version): # writes into files, add. commit def prepare(self, version: Version): # writes into files, add. commit
git_repository = GitRepository() pass
if self.main_branch not in git_repository.get_current_branch():
raise Exception('Trying to release while not on main branch')
self.version_repo.write_file(release_version.get_version_string())
git_repository.add_file(self.file)
git_repository.commit(f'Release {release_version.get_version_string()}')
self.version_repo.write_file(bump_version.get_version_string())
git_repository.add_file(self.file)
git_repository.commit(f'Version bump {bump_version.get_version_string()}')
def tag_and_push(): # correct tag and do push def tag_and_push(): # correct tag and do push
pass pass

View file

@ -36,6 +36,6 @@ def test_init_release_service(tmp_path):
assert "123.124.0" in version.get_version_string() assert "123.124.0" in version.get_version_string()
version = version.create_bump_version() version = release_service.create_bump_version()
assert "123.124.1-SNAPSHOT" in version.get_version_string() assert "123.123.457-SNAPSHOT" in version.get_version_string()