reviewboard.hostingsvcs.hook_utils¶
Utilities for WebHook handlers.
- get_git_branch_name(ref_name: str) str[source]¶
Return the branch name corresponding to the specified ref name.
- get_repository_for_hook(*, repository_id: int, hosting_service_id: str, local_site_name: str | None, hooks_uuid: str | None = None) Repository[source]¶
Return a Repository for the given hook parameters.
Changed in version 7.1: Made arguments keyword-only.
- Parameters:
- Returns:
The repository object.
- Return type:
- Raises:
django.http.Http404 – A repository with the given parameters was not found.
- get_review_request_id(*, commit_message: str, server_url: str, commit_id: str | None = None, repository: reviewboard.scmtools.models.Repository | None = None) int | None[source]¶
Return the review request ID matching the pushed commit.
We first use a regex (that can be overridden in settings_local.py) to try to find a matching review request ID in the commit message. If no match is found with the regex, we then try to find a review request with a matching commit ID.
We assume there is at most one review request associated with each commit. If a matching review request cannot be found, we return None.
Changed in version 7.1: Made arguments keyword-only.
- Parameters:
commit_message (
str) – The commit message from the hosting service.server_url (
str) – The URL to the Review Board server.commit_id (
str) – The ID of the commit.repository (
reviewboard.scmtools.models.Repository) – The repository for the commit.
- Returns:
The ID of the review request that corresponds to the pushed commit. If no review request could be found, this will be
None.- Return type:
- close_review_request(*, review_request: ReviewRequest, review_request_id: int, description: str) None[source]¶
Close the specified review request as submitted.
Changed in version 7.1: Made arguments keyword-only.
- Parameters:
review_request (
reviewboard.reviews.models.ReviewRequest) – The review request to close.review_request_id (
int) – The ID of the review request.description (
str) – The close description to use.
- close_all_review_requests(*, review_request_id_to_commits: Mapping[int | None, Sequence[str]], local_site_name: str | None, repository: Repository, hosting_service_id: str) None[source]¶
Close each review request in the given dictionary as submitted.
The provided dictionary should map a review request ID (int) to commits associated with that review request ID (list of strings). Commits that are not associated with any review requests have the key None.
Changed in version 7.1: Made arguments keyword-only.
- Parameters:
review_request_id_to_commits (
dict) – A mapping from review request ID to a list oflocal_site_name (
str) – The Local Site name, if available.repository (
reviewboard.scmtools.models.Repository) – The repository for all review requests.hosting_service_id (
str) – The name of the hosting service.