Add some useful git functions

This commit is contained in:
bom 2023-02-22 12:04:46 +01:00
parent 1112b1ad49
commit ee8b49f078

View file

@ -1,5 +1,6 @@
import os
import subprocess as sub
from pathlib import Path
from system_repository import SystemRepository
from release_type import ReleaseType
@ -33,3 +34,18 @@ class GitRepository():
else:
return None
def get_current_branch(self):
self.system_repository.run_checked('git', 'branch', '--show-current')
def add_file(self, file_path: Path):
self.system_repository.run_checked('git', 'add', file_path)
def commit(self, commit_message: str):
self.system_repository.run_checked('git', 'commit', '-m', commit_message)
def push(self):
self.system_repository.run_checked('git', 'push')
def checkout(self, branch: str):
self.system_repository.run_checked('git', 'checkout', branch)