|
|
|
@ -3,7 +3,6 @@ from sys import stdout
|
|
|
|
|
from os import chmod, environ
|
|
|
|
|
from pkg_resources import resource_string
|
|
|
|
|
import yaml
|
|
|
|
|
import deprecation
|
|
|
|
|
from subprocess import check_output, Popen, PIPE, run
|
|
|
|
|
from ..domain import Devops, Image, C4k, Release, BuildFile
|
|
|
|
|
|
|
|
|
@ -135,52 +134,50 @@ class CredentialsApi:
|
|
|
|
|
return credential
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GitApi():
|
|
|
|
|
|
|
|
|
|
class GitApi:
|
|
|
|
|
def __init__(self):
|
|
|
|
|
self.execution_api = ExecutionApi()
|
|
|
|
|
|
|
|
|
|
# pylint: disable=invalid-name
|
|
|
|
|
def get_latest_n_commits(self, n: int):
|
|
|
|
|
return self.execution_api.execute(
|
|
|
|
|
f'git log --oneline --format="%s %b" -n {n}')
|
|
|
|
|
return self.execution_api.execute(f'git log --oneline --format="%s %b" -n {n}')
|
|
|
|
|
|
|
|
|
|
def get_latest_commit(self):
|
|
|
|
|
return self.get_latest_n_commits(1)
|
|
|
|
|
|
|
|
|
|
def tag_annotated(self, annotation: str, message: str, count: int):
|
|
|
|
|
return self.execution_api.execute(
|
|
|
|
|
f'git tag -a {annotation} -m {message} HEAD~{count}')
|
|
|
|
|
f"git tag -a {annotation} -m {message} HEAD~{count}"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def tag_annotated_second_last(self, annotation: str, message:str):
|
|
|
|
|
def tag_annotated_second_last(self, annotation: str, message: str):
|
|
|
|
|
return self.tag_annotated(annotation, message, 1)
|
|
|
|
|
|
|
|
|
|
def get_latest_tag(self):
|
|
|
|
|
return self.execution_api.execute('git describe --tags --abbrev=0')
|
|
|
|
|
return self.execution_api.execute("git describe --tags --abbrev=0")
|
|
|
|
|
|
|
|
|
|
def get_current_branch(self):
|
|
|
|
|
return ''.join(self.execution_api.execute('git branch --show-current')).rstrip()
|
|
|
|
|
return "".join(self.execution_api.execute("git branch --show-current")).rstrip()
|
|
|
|
|
|
|
|
|
|
def init(self, default_branch: str = "main"):
|
|
|
|
|
self.execution_api.execute('git init')
|
|
|
|
|
self.execution_api.execute(f'git checkout -b {default_branch}')
|
|
|
|
|
self.execution_api.execute("git init")
|
|
|
|
|
self.execution_api.execute(f"git checkout -b {default_branch}")
|
|
|
|
|
|
|
|
|
|
def set_user_config(self, email: str, name: str):
|
|
|
|
|
self.execution_api.execute(f'git config user.email {email}')
|
|
|
|
|
self.execution_api.execute(f'git config user.name {name}')
|
|
|
|
|
self.execution_api.execute(f"git config user.email {email}")
|
|
|
|
|
self.execution_api.execute(f"git config user.name {name}")
|
|
|
|
|
|
|
|
|
|
def add_file(self, file_path: Path):
|
|
|
|
|
return self.execution_api.execute(f'git add {file_path}')
|
|
|
|
|
return self.execution_api.execute(f"git add {file_path}")
|
|
|
|
|
|
|
|
|
|
def add_remote(self, origin: str, url: str):
|
|
|
|
|
return self.execution_api.execute(f'git remote add {origin} {url}')
|
|
|
|
|
return self.execution_api.execute(f"git remote add {origin} {url}")
|
|
|
|
|
|
|
|
|
|
def commit(self, commit_message: str):
|
|
|
|
|
return self.execution_api.execute(
|
|
|
|
|
f'git commit -m "{commit_message}"')
|
|
|
|
|
return self.execution_api.execute(f'git commit -m "{commit_message}"')
|
|
|
|
|
|
|
|
|
|
def push(self):
|
|
|
|
|
return self.execution_api.execute('git push')
|
|
|
|
|
return self.execution_api.execute("git push")
|
|
|
|
|
|
|
|
|
|
def checkout(self, branch: str):
|
|
|
|
|
return self.execution_api.execute(f'git checkout {branch}')
|
|
|
|
|
return self.execution_api.execute(f"git checkout {branch}")
|
|
|
|
|