Run¶
A Run connects packages with repositories. rcmt reads the Run, finds repositories and then applies packages to each repository.
- class rcmt.run.Run(name, auto_merge=False, auto_merge_after=None, branch_name='', merge_once=False, pr_body='', pr_title='')¶
A Run connects packages with repositories. rcmt reads the Run, finds repositories and packages and then applies these packages to each repository.
- Parameters
name (
str
) – The name of the Run. rcmt uses the name to identify a run.auto_merge (
bool
) – rcmt automatically merges a pull request on its next run. The pull request must pass all its checks.auto_merge_after (
Optional
[timedelta
]) – A duration after which to automatically merge a Pull Request. Requiresauto_merge
to be set totrue
.branch_name (
str
) – Name of the branch in git. Defaults tobranch_prefix
+name
.merge_once (
bool
) – IfTrue
, rcmt does not create another pull request if it created a pull request for the same branch before and that pull request has been merged.pr_body (
str
) – Define a custom body of a pull request.pr_title (
str
) – Set a custom title for a pull request.
Example
from datetime import timedelta from rcmt import Run from rcmt.matcher import FileExists, RepoName with Run( name="python-defaults", auto_merge=True, auto_merge_after=timedelta(days=7) ) as run: run.add_matcher(FileExists("pyproject.toml")) run.add_matcher(RepoName("^github.com/wndhydrnt/rcmt$")) run.add_package("flake8") run.pr_title = "A custom PR title" run.pr_body = '''A custom PR title. It supports multiline strings.'''
- add_matcher(m)¶
Add a Matcher that matches repositories.
- Parameters
m (
Base
) – The matcher to add.- Return type
None
- add_package(name)¶
Add a Package to apply to every matching repository.
- Parameters
name (
str
) – The name of the Package.- Return type
None
Matchers¶
A Run uses Matchers to find the repositories to which it applies Packages.
FileExists¶
- class rcmt.matcher.FileExists(path)¶
FileExists matches if the file exists in a repository.
The code checks for the existence of a file by calling the API of the Source. This prevents useless checkouts of repositories and saves bandwidth.
- Parameters
path (
str
) – Path to the file, relative to the root of the repository.
RepoName¶
- class rcmt.matcher.RepoName(search)¶
RepoName matches if the name of a repository matches a regular expression.
- Parameters
search (
str
) – Regular expression to test against names of repositories.
Base Class¶
- class rcmt.matcher.Base¶
Base class that describes the methods of a Matcher.
- match(repo)¶
Indicates if a repository matches.
- Parameters
repo (
Repository
) – Repository to check.- Return type
bool
- Returns