gerrit_to_platform package¶
Submodules¶
gerrit_to_platform.change_merged module¶
Handler for patchset-created events.
- gerrit_to_platform.change_merged.change_merged(change: str, change_url: str, change_owner: str, change_owner_username: str, project: str, branch: str, topic: str, submitter: str, submitter_username: str, commit: str, newrev: str)[source]¶
Handle change-merged hook.
- Parameters:
change (str) – change ID
change_url (str) – change URL
change_owner (str) – change owner eg: ‘Foo <foo@example.com>’
change_owner_username (str) – change owner username eg: ‘foo’
project (str) – Gerrit project name
branch (str) – branch change is against
topic (str) – topic change is part of
submitter (str) – submitter of change eg: ‘Foo <foo@example.com>’
submitter_username (str) – submitter of change username eg: ‘foo’
commit (str) – SHA1 of commit
newrev (str) – SHA1 of commit
gerrit_to_platform.comment_added module¶
Handler for patchset-created events.
- gerrit_to_platform.comment_added.comment_added(context: Context, change: str, change_url: str, change_owner: str, change_owner_username: str, project: str, branch: str, topic: str, author: str, author_username: str, commit: str, comment: str)[source]¶
Handle comment-added hook.
Approval scores should be added as –<approval category id> <score>
When a score is removed it should be –<approval category id>-oldValue <score>
Multiple scores and old scores may be passed
ex: –Code-Review +1 –Code-Review-oldValue 0
- Parameters:
context (typer.Context) – handler for the typer context to allow for extra non-defined parameters (code scores, see above)
change (str) – change ID
change_url (str) – change URL
change_owner (str) – change owner eg: ‘Foo <foo@example.com>’
change_owner_username (str) – change owner username eg: ‘foo’
project (str) – Gerrit project name
branch (str) – branch change is against
topic (str) – topic change is part of
submitter (str) – submitter of change eg: ‘Foo <foo@example.com>’
submitter_username (str) – submitter of change username eg: ‘foo’
commit (str) – SHA1 of commit
comment (str) – the comment added to the change
gerrit_to_platform.config module¶
Configuration subsystem.
- class gerrit_to_platform.config.Platform(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
Enum
Enumeration of all platforms recognized by the app.
- GITHUB = 'github'¶
- GITLAB = 'gitlab'¶
- class gerrit_to_platform.config.ReplicationRemotes[source]¶
Bases:
TypedDict
Platform Dictionary definition.
- gerrit_to_platform.config.get_config(config_type: str = 'config') ConfigParser [source]¶
Get the config object.
- Parameters:
config_type (str) – Type of configuration file that the parser should use
- Returns:
- A loaded ConfigParser object with the requested
configuration file
- Return type:
ConfigParser
- gerrit_to_platform.config.get_mapping(mapping_section: str) Dict[str, str] | None [source]¶
Return all of the keyword to job mappings
- gerrit_to_platform.config.get_replication_remotes() ReplicationRemotes [source]¶
Get the replication remotes available.
- Returns:
- All the replication remotes defined the Gerrit
configuration file
- Return type:
gerrit_to_platform.github module¶
Github connection module.
- gerrit_to_platform.github.dispatch_workflow(owner: str, repository: str, workflow_id: str, ref: str, inputs: Dict[str, str]) Any [source]¶
Trigger target workflow on GitHub.
- gerrit_to_platform.github.filter_path(search_filter: str, workflow: Dict[str, str]) bool [source]¶
Case insensitive path filter for use in lambda filters.
- gerrit_to_platform.github.filter_workflows(owner: str, repository: str, search_filter: str, search_required: bool = False) List[Dict[str, str]] [source]¶
Return a case insensitive filtered list of workflows.
All workflows must meet the basic filtering of containing the search_filter in the name as well as “gerrit” in the name.
If search_required is true, then the list will contiain all workflows that contain “required” in the name
If search_required is false (the default), then the list will _exclude_ all workflows that contain “required” in the name.
- Parameters:
owner (str) – GitHub owner (entity or organization)
repository (str) – target repository
search_filter (str) – the substring to search for in workflow filenames
search_required (bool) – if workflows with “required” in the filename are to be returned. If false, then required workflows will be filtered out, if true only required workflows will be returned.
- Returns:
- list of dictionaries containing all workflows
that meet the search criteria of having “gerrit” in the name, the search_filter substring, and either required or not required according to the search_required argument.
- Return type:
gerrit_to_platform.helpers module¶
Common helper functions.
- gerrit_to_platform.helpers.choose_dispatch(platform: Platform) Callable | None [source]¶
Choose platform job dispatcher.
- Parameters:
platform (Platform) – the platform that the dispatch is being looked up for
- Returns:
- The appropriate callable matching the dispatch_worfklow call
signature for the platform
- None: If no dispatch_workflow is defined for the platform passed in a
None is returned
- Return type:
Callable
- gerrit_to_platform.helpers.choose_filter_workflows(platform: Platform) Callable | None [source]¶
Choose platform workflow filter.
- Parameters:
platform (Platform) – the platform that the filter_workflows is being looked up for
- Returns:
- The appropriate callable matching the filter_workflows call
signature for the platform
- None: If no filter_workflows is defined for the platform passed in a
None is returned
- Return type:
Callable
- gerrit_to_platform.helpers.convert_repo_name(remotes: ReplicationRemotes, platform: Platform, remote: str, repository: str) str [source]¶
Convert the repository name based on the remotenamestyle of the target platform/owner.
- Parameters:
remotes (ReplicationRemotes) – object containing the defined remotes styles
platform (Platform) – what platform is the conversion happening against
remote (str) – The specific remote that is being worked on
repository (str) – The repository name that needs conversion
- Returns:
- The repository name converted to the appropriate flattening for
the target remote
- Return type:
- gerrit_to_platform.helpers.find_and_dispatch(project: str, workflow_filter: str, inputs: Dict[str, str])[source]¶
Find relevant workflows and dispatch them.
- gerrit_to_platform.helpers.get_change_id(change: str) str [source]¶
Get the Gerrit change_id from an hook event.
- gerrit_to_platform.helpers.get_change_number(change_url: str) str [source]¶
Get the Gerrit change_number
- gerrit_to_platform.helpers.get_change_refspec(change_number: str, patchset: str) str [source]¶
Return the change refspec from the change number (str) and patch number
gerrit_to_platform.patchset_created module¶
Handler for patchset-created events.
- gerrit_to_platform.patchset_created.patchset_created(change: str, kind: str, change_url: str, change_owner: str, change_owner_username: str, project: str, branch: str, topic: str, uploader: str, uploader_username: str, commit: str, patchset: str)[source]¶
Handle patcheset-created hook.
- Parameters:
change (str) – change ID
kind (str) – type of change
change_url (str) – change URL
change_owner (str) – change owner eg: ‘Foo <foo@example.com>’
change_owner_username (str) – change owner username eg: ‘foo’
project (str) – Gerrit project name
branch (str) – branch change is against
topic (str) – topic change is part of
uploader (str) – uploader of change eg: ‘Foo <foo@example.com>’
uploader_username (str) – uploader of change username eg: ‘foo’
commit (str) – SHA1 of commit
patchset (str) – patchset number