def push(self, branch): """ Executes git push :param branch: branch to push :return: """ success = run_command(self.repo_path, f'git push origin {branch}', '', False) if not success: raise GitException(f"Can't push branch {branch} to origin!")
def commit(self, message='release commit', allow_empty=False): """ Executes git commit :param message: commit message :return: """ arg = '--allow-empty' if allow_empty else '' success = run_command(self.repo_path, f'git commit {arg} -m \"{message}\"', '', False) if not success: raise GitException(f"Can't commit files!")
def add(self, files: list): """ Executes git add :param files: list of files to add :return: """ for file in files: success = run_command(self.repo_path, f'git add {file}', '', False) if not success: raise GitException(f"Can't git add file {file}!")
def clone(url): """ Clones repository from url to temporary directory :param url: :return: TemporaryDirectory object """ temp_directory = TemporaryDirectory() if not run_command(temp_directory.name, f'git clone {url} .', "Couldn't clone repository!", fail=False): raise GitException(f"Can't clone repository {url}") return temp_directory
def commit(self, message="release commit", allow_empty=False): """ Executes git commit :param message: commit message :return: """ arg = "--allow-empty" if allow_empty else "" success = run_command( self.repo_path, f'git commit {arg} -m "{message}"', "", False ) if not success: raise GitException("Can't commit files!")
def clone(url): """ Clones repository from url to temporary directory :param url: :return: TemporaryDirectory object """ temp_directory = mkdtemp() if not run_command( temp_directory, f"git clone {url} .", "Couldn't clone repository!", fail=True, ): raise GitException(f"Can't clone repository {url}") return temp_directory