Sources

A Source hosts git repositories. rcmt uses a Source to match Packages to repositories, clones the repositories that match and applies Packages to their data. It creates a pull request via the Source if a Package changes files.

rcmt supports the following Sources:

Base Classes

class rcmt.source.Base

Base defines the methods every Source needs to implement.

list_repositories()
Returns

List of all known repositories.

Return type

list[rcmt.source.Repository]

class rcmt.source.Repository

Repository provides all methods needed to interact with a single repository of a Source.

property base_branch: str
Returns

Name of the base branch of this repository.

Return type

str

property clone_url: str
Returns

Url to clone this repository.

Return type

str

create_pull_request(branch, pr)

Creates a pull request for the given branch.

Parameters
  • branch (str) – Name of the branch.

  • pr (PullRequest) – The pull request.

Return type

None

find_pull_request(branch)

Finds and returns the pull request opened by rcmt.

Parameters

branch (str) – Name of the branch from which a pull request has been created.

Returns

Implementation of this method should return None if no pull request is open. Any other value will be passed to merge_pull_request() so it can identify which PR to merge.

Return type

Any, None

has_file(path)

Checks if a file exists in a repository.

rcmt calls this function when matching repositories. This is more efficient than checking out the whole repository to check if a file exists.

Parameters

path (str) – Path to a file or directory in the repository.

Returns

Indicates if the files exists.

Return type

bool

has_successful_pr_build(identifier)

Checks if a pull request has passed all checks. rcmt will call merge_pull_request if this function returns True.

Parameters

identifier (Any) – Data to identify the pull request as returned by find_pull_request.

Returns

Indicates if the build is successful.

Return type

bool

is_pr_closed(identifier)

Checks if a pull request has been closed by the user. A pull request is closed if a user manually closes it without merging it. If a user has closed a pull request without merging it, rcmt will not create a new one.

Parameters

identifier (Any) – Data to identify the pull request as returned by find_pull_request.

Returns

Indicates that a pull request has been closed by the user.

Return type

bool

is_pr_merged(identifier)

Checks if a pull request has been merged. rcmt uses this information to determine if it can create new pull requests.

Parameters

identifier (Any) – Data to identify the pull request as returned by find_pull_request.

Returns

Indicates that a pull request has been merged.

Return type

bool

is_pr_open(identifier)

Checks if a pull request is open. rcmt will attempt to merge the pull request if this method returns true and there are no new changes from packages.

Parameters

identifier (Any) – Data to identify the pull request as returned by find_pull_request.

Returns

Indicates that a pull request is open.

Return type

bool

merge_pull_request(identifier)

Merges a pull request.

Parameters

identifier (Any) – Data to identify the pull request as returned by find_pull_request.

Return type

None

property name: str
Returns

Name of the repository.

Return type

str

pr_created_at(pr)

Returns the date and time at which the pull request was created.

Parameters

pr (Any) – The pull request identifier as returned by find_pull_request().

Returns

Date and time at which the pull request was created.

Return type

datetime.datetime

property project: str
Returns

Name of the project the repository belongs to.

Return type

str

property source: str
Returns

Name of the source that hosts the repository.

Return type

str