ci_diff_helper.git_tools module

Helpers for interacting with git.

ci_diff_helper.git_tools.commit_subject(revision='HEAD')[source]

Gets the subject of a git commit.

Parameters:revision (Optional [ str ]) – A git revision, any of a branch name, tag, a commit SHA or a special reference.
Returns:The commit subject.
Return type:str
ci_diff_helper.git_tools.get_changed_files(blob_name1, blob_name2)[source]

Gets a list of changed files between two git revisions.

A git object reference can be any of a branch name, tag, a commit SHA or a special reference.

Parameters:
  • blob_name1 (str) – A git object reference.
  • blob_name2 (str) – A git object reference.
Returns:

List of all filenames changed.

Return type:

list

ci_diff_helper.git_tools.get_checked_in_files()[source]

Gets a list of files in the current git repository.

Effectively runs:

$ git ls-files ${GIT_ROOT}

and then finds the absolute path for each file returned.

Returns:List of all filenames checked into the repository.
Return type:list
ci_diff_helper.git_tools.git_root()[source]

Return the root directory of the current git checkout.

Returns:Filesystem path to git checkout root.
Return type:str
ci_diff_helper.git_tools.merge_commit(revision='HEAD')[source]

Checks if a git revision is a merge commit.

Parameters:revision (Optional [ str ]) – A git revision, any of a branch name, tag, a commit SHA or a special reference.
Returns:Flag indicating if the given revision.
Return type:bool
Raises:NotImplementedError – if the number of parents is not 1 or 2.