Compare commits
No commits in common. "0b3daf595a36346bd25e6f9d80defb634be9babe" and "94b993ccf5a7ecea53c85a9e3a738576c08fcf31" have entirely different histories.
0b3daf595a
...
94b993ccf5
3 changed files with 59 additions and 39 deletions
|
@ -1,7 +1,5 @@
|
|||
import os
|
||||
import subprocess as sub
|
||||
from system_repository import SystemRepository
|
||||
from release_type import ReleaseType
|
||||
|
||||
# define semantics for release types by commit messages
|
||||
## snapshot - snapshot release
|
||||
|
@ -16,19 +14,64 @@ FORMAT = '"%h %s"'
|
|||
FORMAT_DEC = "%d"
|
||||
PRETTY_OPTION = '--pretty='
|
||||
DECORATE_OPTION = '--decorate=full'
|
||||
|
||||
|
||||
# git log --oneline --format="%s %b" origin/master...HEAD
|
||||
|
||||
|
||||
class GitRepo():
|
||||
|
||||
def __init__(self):
|
||||
self.latest_commit = None
|
||||
self.system_repository = SystemRepository()
|
||||
self.commits = None
|
||||
self.tags = None
|
||||
|
||||
def get_latest_commit(self):
|
||||
self.latest_commit = self.system_repository.run_checked('git', 'log', '--oneline', '--format="%s %b"', '-n' + '1')
|
||||
def __clean_commit_string(self, commit_string):
|
||||
return commit_string.replace('\"', "").replace('\n', "").split()
|
||||
|
||||
def get_release_type_from_latest_commit(self):
|
||||
if self.latest_commit is None:
|
||||
self.get_latest_commit()
|
||||
def __clean_tag_string(self, tag_string):
|
||||
return tag_string.replace(" ", "").replace('\n', "")
|
||||
|
||||
def get_tags(self):
|
||||
stream = sub.Popen([GIT,
|
||||
LOG,
|
||||
PRETTY_OPTION + FORMAT_DEC,
|
||||
DECORATE_OPTION],
|
||||
stdout=sub.PIPE,
|
||||
stderr=sub.PIPE,
|
||||
text=True,
|
||||
encoding="UTF-8")
|
||||
stdout = stream.stdout.readlines()
|
||||
stderr = stream.stderr.readlines()
|
||||
|
||||
if len(stderr) > 0:
|
||||
raise Exception(f"Git command failed with: {stderr}")
|
||||
|
||||
return stdout
|
||||
|
||||
def get_commits(self):
|
||||
stream = sub.Popen([GIT,
|
||||
LOG,
|
||||
PRETTY_OPTION + FORMAT],
|
||||
stdout=sub.PIPE,
|
||||
stderr=sub.PIPE,
|
||||
text=True,
|
||||
encoding="UTF-8")
|
||||
stdout = stream.stdout.readlines()
|
||||
stderr = stream.stderr.readlines()
|
||||
|
||||
if len(stderr) > 0:
|
||||
raise Exception(f"Git command failed with: {stderr}")
|
||||
|
||||
self.tags = self.get_tags()
|
||||
self.commits = {}
|
||||
|
||||
if len(self.tags) != len(stdout):
|
||||
raise Exception("Tags list did not match commits list")
|
||||
|
||||
for i, elem in enumerate(stdout):
|
||||
commit_string = self.__clean_commit_string(elem)
|
||||
|
||||
commit_id = commit_string[0]
|
||||
commit_message = " ".join(commit_string[1:len(commit_string)])
|
||||
commit_tag = self.__clean_tag_string(self.tags[i])
|
||||
|
||||
self.commits[commit_id] = [commit_tag, commit_message]
|
||||
|
||||
return self.commits
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
from version_repository import VersionRepository
|
||||
from release_type import ReleaseType
|
||||
|
||||
import version_repository
|
||||
import release_type
|
||||
class InitReleaseService():
|
||||
|
||||
def __init__(self, commit_id, file):
|
||||
|
@ -16,7 +15,7 @@ class InitReleaseService():
|
|||
|
||||
def get_version(self, release_type):
|
||||
self.version_repo = VersionRepository(self.file)
|
||||
return self.version_repo.get_version(release_type)
|
||||
return repo.get_version(release_type)
|
||||
|
||||
def create_release_version(self):
|
||||
commit_message = self.read_commit_message(self.commit_id)
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
import subprocess as sub
|
||||
|
||||
class SystemRepository():
|
||||
|
||||
def __init__(self):
|
||||
self.stdout = [""]
|
||||
self.stderr = [""]
|
||||
|
||||
def run(self, *args):
|
||||
stream = sub.Popen(args,
|
||||
stdout=sub.PIPE,
|
||||
stderr=sub.PIPE,
|
||||
text=True,
|
||||
encoding="UTF-8")
|
||||
self.stdout = stream.stdout.readlines()
|
||||
self.stderr = stream.stderr.readlines()
|
||||
|
||||
def run_checked(self, *args):
|
||||
self.run(args)
|
||||
|
||||
if len(self.stderr) > 0:
|
||||
raise Exception(f"Command failed with: {self.stderr}")
|
Loading…
Reference in a new issue