dda-devops-build/git_handler.py

35 lines
943 B
Python
Raw Normal View History

2023-02-21 14:08:39 +00:00
import os
import subprocess as sub
2023-02-22 08:59:35 +00:00
from system_repository import SystemRepository
from release_type import ReleaseType
2023-02-21 14:08:39 +00:00
# define semantics for release types by commit messages
## snapshot - snapshot release
## fix/patch - patch release
## bump - version bump release
## feature/feat/minor - minor release
## major/breaking - major release
GIT = 'git'
LOG = 'log'
FORMAT = '"%h %s"'
FORMAT_DEC = "%d"
PRETTY_OPTION = '--pretty='
DECORATE_OPTION = '--decorate=full'
2023-02-22 08:59:35 +00:00
# git log --oneline --format="%s %b" origin/master...HEAD
2023-02-21 14:08:39 +00:00
2023-02-22 08:59:35 +00:00
class GitRepo():
2023-02-21 14:08:39 +00:00
2023-02-22 08:59:35 +00:00
def __init__(self):
self.latest_commit = None
self.system_repository = SystemRepository()
2023-02-21 14:08:39 +00:00
2023-02-22 08:59:35 +00:00
def get_latest_commit(self):
self.latest_commit = self.system_repository.run_checked('git', 'log', '--oneline', '--format="%s %b"', '-n' + '1')
2023-02-21 14:08:39 +00:00
2023-02-22 08:59:35 +00:00
def get_release_type_from_latest_commit(self):
if self.latest_commit is None:
self.get_latest_commit()