GitRepo (autotransform.repo.git)¶
The implementation for the GitRepo.
- class autotransform.repo.git.GitRepo(*, base_branch: str)¶
Bases:
Repo
A Repo that provides support for commiting changes to git.
- base_branch¶
The name of the base branch for the repository.
- Type:
str
- name¶
The name of the component.
- Type:
ClassVar[str]
- BRANCH_NAME_PREFIX¶
The prefix to apply to branches that are created.
- Type:
ClassVar[str]
- COMMIT_MESSAGE_PREFIX¶
The prefix to apply to commits that are created.
- Type:
ClassVar[str]
- BRANCH_NAME_PREFIX: ClassVar[str] = 'AUTO_TRANSFORM'¶
- COMMIT_MESSAGE_PREFIX: ClassVar[str] = '[AutoTransform]'¶
- base_branch: str¶
- clean(_batch: Batch) None ¶
Performs git reset –hard to remove any changes.
- Parameters:
_batch (Batch) – Unused Batch object used to match signature to base
- commit(title: str, update: bool) None ¶
Creates a new branch for all changes, stages them, and commits them.
- Parameters:
title (str) – The title of the Batch being commited.
update (bool) – Whether to update an existing change.
- static get_branch_name(title: str) str ¶
Gets a unique name for a git branch using the title from the Batch.
- Parameters:
title (str) – The title of the change.
- Returns:
The name of the branch for this change.
- Return type:
str
- get_changed_files(_batch: Batch) List[str] ¶
Uses git status to get all changed files.
- Parameters:
_batch (Batch) – Unused Batch object used to match signature to base.
- Returns:
All changed files, including untracked files.
- Return type:
List[str]
- static get_changed_files_from_status(status: str) List[str] ¶
Parses the git status to get the changed files.
- Parameters:
status (str) – The result of git status -s –untracked-files
- Returns:
The changed files.
- Return type:
List[str]
- static get_commit_message(title: str) str ¶
Gets a commit message for the change based on the Batch title.
- Parameters:
title (str) – The title of the change.
- Returns:
The commit message for this change.
- Return type:
str
- get_outstanding_changes() Sequence[Change] ¶
Gets all outstanding Changes for the Repo.
- Returns:
The outstanding Changes against the Repo.
- Return type:
Sequence[Change]
- has_outstanding_change(batch: Batch) bool ¶
Checks the state of the repo to see whether an outstanding Change for the Batch exists.
- Parameters:
batch (Batch) – The Batch to check for.
- Returns:
Whether an outstanding Change exists.
- Return type:
bool
- rewind(batch: Batch) None ¶
First eliminates any uncommitted changes using the clean function then checks out the initial active branch.
- Parameters:
batch (Batch) – The Batch for the submitted changes that is being rewound.