예제 #1
0
 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!")
예제 #2
0
 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!")
예제 #3
0
 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}!")
예제 #4
0
 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
예제 #5
0
 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!")
예제 #6
0
 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