Finish refactoring for ExecutionAPI

merge-requests/6/merge
bom 1 year ago
parent 5fe58e95cd
commit 54f3938088

@ -221,58 +221,49 @@ class GitApi():
self.execution_api = ExecutionApi()
def get_latest_n_commits(self, n: int):
self.execution_api.execute(
return self.execution_api.execute(
f'git log --oneline --format="%s %b" -n {n}')
return self.execution_api.stdout
def get_latest_commit(self):
output = self.get_latest_n_commits(1)
return " ".join(output)
return self.get_latest_n_commits(1)
def tag_annotated(self, annotation: str, message: str, count: int):
self.execution_api.execute(
'git', 'tag', '-a', annotation, '-m', message, f'HEAD~{count}')
return self.execution_api.stdout
return self.execution_api.execute(
f'git tag -a {annotation} -m {message} HEAD~{count}')
def tag_annotated_second_last(self, annotation: str, message:str):
self.tag_annotated(annotation, message, 1)
return self.execution_api.stdout
return self.tag_annotated(annotation, message, 1)
def get_latest_tag(self):
self.execution_api.execute('git', 'describe', '--tags', '--abbrev=0')
return self.execution_api.stdout
return self.execution_api.execute('git describe --tags --abbrev=0')
def get_current_branch(self):
self.execution_api.execute('git', 'branch', '--show-current')
self.execution_api.execute('git branch --show-current')
return ''.join(self.execution_api.stdout).rstrip()
def init(self, default_branch: str = "main"):
self.execution_api.execute('git', 'init', '-b', default_branch)
self.execution_api.execute(f'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('git', 'config', 'user.email', email)
self.execution_api.execute('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):
self.execution_api.execute('git', 'add', file_path)
return self.execution_api.stdout
return self.execution_api.execute(f'git add {file_path}')
def add_remote(self, origin: str, url: str):
self.execution_api.execute('git', 'remote', 'add', origin, url)
return self.execution_api.stdout
return self.execution_api.execute(f'git remote add {origin} {url}')
def commit(self, commit_message: str):
self.execution_api.execute(
'git', 'commit', '-m', commit_message)
return self.execution_api.stdout
return self.execution_api.execute(
f'git commit -m "{commit_message}"')
def push(self):
self.execution_api.execute('git', 'push')
return self.execution_api.stdout
return self.execution_api.execute('git push')
def checkout(self, branch: str):
self.execution_api.execute('git', 'checkout', branch)
return self.execution_api.stdout
return self.execution_api.execute(f'git checkout {branch}')
class EnvironmentApi():

Loading…
Cancel
Save