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

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

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: Mapping[str, Any] | None, change: Change | None = 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'