From ee8b49f078eb200f5b4127193b9f321de3fd2705 Mon Sep 17 00:00:00 2001 From: bom Date: Wed, 22 Feb 2023 12:04:46 +0100 Subject: [PATCH] Add some useful git functions --- git_repository.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/git_repository.py b/git_repository.py index 83c9ea5..f891646 100644 --- a/git_repository.py +++ b/git_repository.py @@ -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) +