Module ploigos_step_runner.utils.git
Shared utils for git operations.
NOTE: There is heavy overlap between this class and GitMixin. An architectural decision needs
to be made on composition vs. multiple inheritance for gaining consistency between unrelated
step implementers that require the same configuration parameters / behaviors.
Functions
def clone_repo(repo_dir, repo_url, username=None, password=None)-
Clones the repository specified in repo_url.
Parameters
repo_dir:str- Path to where to clone the repository
repo_url:str- URI of the repository to clone.
username:str- Username for the remote git repo (if required)
password:str- Password for the remote git repo (if required)
Raises
StepRunnerException
- if error cloning repository
def get_git_repo_regex()-
Getter for the StepImplementer's configuration defaults.
Returns
str- The regex representing a valid git repo URI.
def git_checkout(repo_dir, repo_branch)-
Checks out a specifc branch in the given git repository.
Parameters
repo_dir:str- Path to an existing git repository
repo_branch:str- The branch to checkout.
Raises
StepRunnerException
- if error checking out branch of repository
def git_commit_file(git_commit_message, file_path, repo_dir)-
Adds and commits a file. NOTE: In the future, this should be split between two methods, to allow adding multiple files before committing.
Parameters
git_commit_message:str- The message to apply on commit.
file_path:str- The file to commit.
repo_dir:str- Path to an existing git repository.
Raises
StepRunnerException
- if error adding or committing the file
def git_config(repo_dir, git_email, git_name)-
Sets the git config (username + email) for the git repository residing under repo_dir.
Parameters
repo_dir:str- Path to where to clone the repository
git_email:str- email to use when performing git operations in the cloned repository
git_name:str- name to use when performing git operations in the cloned repository
Raises
StepRunnerException
- if error configuring repo user
def git_tag_and_push(repo_dir, tag, url=None, force_push_tags=False)-
Tags a commit and pushes it. NOTE: In the future, this should be split between two methods, to allow additional actions after tagging without requiring multiple pushes.
Parameters
repo_dir:str- Path to an existing git repository.
tag:str- Tag (label) to apply.
url:str- URI of git repo, if different than the default as configured under repo_dir.
force_push_tags:bool- Whether to force push when history between the local and remote branch differs.
Raises
StepRunnerException
- if error pushing commits
- if error tagging repository
- if error pushing tags