Repo (autotransform.repo.base)

The base class and associated classes for Repo components.

class autotransform.repo.base.Repo

Bases: NamedComponent

The base for Repo components. Used by AutoTransform to interact with version control and code review systems.

name

The name of the component.

Type

ClassVar[RepoName]

abstract clean(batch: Batch) None

Clean any changes present in the Repo that have not been submitted.

Parameters

batch (Batch) – The Batch for which we are cleaning the repo.

abstract get_changed_files(batch: Batch) List[str]

Gets all files in the repo that have been modified.

Parameters

batch (Batch) – The Batch that was used for the transformation

Returns

The list of files that have unsubmitted changes.

Return type

List[str]

abstract get_outstanding_changes() Sequence[Change]

Gets all outstanding Changes for the Repo.

Returns

The outstanding Changes against the Repo.

Return type

Sequence[Change]

has_changes(batch: Batch) bool

Check whether any changes have been made to the underlying code based on the Batch.

Parameters

batch (Batch) – The Batch that was used for the transformation.

Returns

Returns True if there are any changes to the codebase.

Return type

bool

abstract 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

name: ClassVar[RepoName]
abstract rewind(batch: Batch) None

Rewind the repo to a pre-submit state to prepare for executing another Batch. This should NOT delete any submissions (i.e. commits should stay present).

Parameters

batch (Batch) – The Batch for which changes were submitted.

abstract submit(batch: Batch, transform_data: Optional[Mapping[str, Any]], change: Optional[Change] = None) None

Submit the changes to the Repo (i.e. commit, submit Pull Request, etc…). Only called when changes are present.

Parameters
  • batch (Batch) – The Batch for which the changes were made.

  • transform_data (Optional[Mapping[str, Any]]) – Data from the transformation.

  • change (Optional[Change]) – An associated change which should be updated. Defaults to None.

class autotransform.repo.base.RepoName(value)

Bases: str, Enum

A simple enum for mapping.

GIT = 'git'
GITHUB = 'github'