Add utility functions to git_repository

This commit is contained in:
bom 2023-02-23 15:33:00 +01:00
parent fa6beebc4e
commit e7152301dd

View file

@ -16,9 +16,14 @@ class GitRepository():
inst.latest_commit = commit_string
return inst
def get_latest_n_commits(self, n: int):
self.system_repository.run_checked('git', 'log', '--oneline', '--format="%s %b"', f'-n {n}')
return self.system_repository.stdout
def get_latest_commit(self):
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
output = self.get_latest_n_commits(1)
self.latest_commit = " ".join(output) # returns a list of strings otherwise
return self.latest_commit
def get_release_type_from_latest_commit(self):
if self.latest_commit is None:
@ -38,6 +43,9 @@ class GitRepository():
def tag_annotated(self, annotation: str, message: str):
self.system_repository.run_checked('git', 'tag', '-a', annotation, '-m', message)
def tag_annotated(self, annotation: str, message: str, count: int):
self.system_repository.run_checked('git', 'tag', '-a', annotation, '-m', message, f'HEAD~{count}')
def get_current_branch(self):
self.system_repository.run_checked('git', 'branch', '--show-current')