atudomain.git¶
-
class
atudomain.git.Git(directory: str, executable_directory='')¶ Represents git repository. Can be used to extract Commits and examine branches. It can also be used to conveniently run git commands and get their output.
- Parameters
directory (str) – Path to git repository or bare repository.
executable_directory (str) – Path to directory with git binary.
-
add_files(pathspec: str)¶ Adds files to stash.
- Parameters
pathspec (str) – Git-add-compatible single-word expression.
-
checkout(target: str)¶ Checkouts to specified target.
- Parameters
target (str) – Branch, commit or other target.
-
checkout_new_branch(branch: str)¶ Creates new branch and checkouts to it.
- Parameters
branch (str) – Name of branch.
-
commit(message: str)¶ Creates a commit in a non-interactive way.
- Parameters
message (str) – Commit message.
-
config(name: str, value: str)¶ Changes git config values in current repository.
- Parameters
name (str) – Name of entry to change.
value (str) – New value for entry.
-
get_branches(include=None, exclude=None) → List[str]¶ Extracts branch names from ‘git branch –all’ command and appends them to a list. Skips redundant information such as current branch pointer (‘*’) or relations (‘->’).
- Parameters
include (str) – Regex (re module) to include branch names in list. None means all.
exclude (str) – Regex (re module) to exclude branch names from list.
- Returns
List of branch names.
- Return type
List[str]
-
get_commits(revision_range='') → List[atudomain.git.objects.Commit]¶ Extracts commits from git ‘log –pretty=raw’ command, creates Commit objects from them and appends them to a list.
- Parameters
revision_range (str) – Any revision range that could be used with git log command.
- Returns
List of Commit objects extracted.
- Return type
List[Commit]
-
pull()¶ Equivalent of ‘git pull’ without arguments.
-
push(remote='origin', branch='', set_upstream=False)¶ Pushes to specific branch in specific remote.
- Parameters
remote (str) – Name of remote.
branch (str) – Name of branch.
set_upstream (bool) – If specified branch should become upstream.
-
class
atudomain.git.Commit(is_merge: bool, commit_id: str, tree: str, parents: List[str], author: str, author_email: str, author_date: datetime.datetime, committer: str, committer_email: str, committer_date: datetime.datetime, message: str, message_subject: str, message_body: str)¶ Represents git repository commit as extracted from ‘git log –pretty=raw’. Stores data as properties and has additional methods for getting dates as strings.
- Return type
str
- Return type
datetime.datetime
- Return type
str
-
property
commit_id¶ - Return type
str
-
property
committer¶ - Return type
str
-
property
committer_date¶ - Return type
datetime.datetime
-
property
committer_email¶ - Return type
str
Converts stored datetime author_date to UTC+0 string date.
- Parameters
date_format (str) – Optional date format as for datetime.strftime method.
- Returns
Converted date.
- Return type
str
-
get_committer_date_string(date_format='%Y-%m-%d %H:%M:%S %z') → str¶ Converts stored datetime committer_date to UTC+0 string date.
- Parameters
date_format (str) – Optional date format as for datetime.strftime method.
- Returns
Converted date.
- Return type
str
-
property
is_merge¶ - Return type
bool
-
property
message¶ - Return type
str
-
property
message_body¶ - Return type
str
-
property
message_subject¶ - Return type
str
-
property
parents¶ - Return type
List[str]
-
property
tree¶ - Return type
str