rbtools.hooks.common¶
Common functionality for working with repository hooks.
Functions
|
Closes the specified review request as submitted. |
|
Execute the specified command and return the stdout output. |
|
Returns an RBClient instance and the associated root resource. |
|
Returns the review request resource for the given ID. |
|
Returns the approval information for the given review request. |
|
Returns the review request ID referenced in the commit message. |
|
Sets up a log handler to format log messages. |
Exceptions
- rbtools.hooks.common.get_api(server_url, **kwargs)[source]¶
Returns an RBClient instance and the associated root resource.
Hooks should use this method to gain access to the API, instead of instantiating their own client.
- Parameters:
server_url (
unicode
) – The server URL to retrieve.**kwargs (
dict
) – Additional keyword arguments to pass to theRBClient
constructor. SeeSyncTransport.__init__()
for arguments that are accepted.
- Returns:
This returns a 2-tuple of the
RBClient
and<root resource> rbtools.api.resource.Resource
.- Return type:
- rbtools.hooks.common.execute(command: Union[List[str], str], *, text: bool = False, strip: bool = True) Optional[Union[bytes, str]] [source]¶
Execute the specified command and return the stdout output.
Changed in version 5.0: Added the
text
andstrip
arguments.Deprecated since version 5.0: Deprecated in favor of
run_process()
.- Parameters:
- Returns:
The stdout output of the command or
None
if the command failed to execute.- Return type:
- rbtools.hooks.common.initialize_logging(debug: bool = False) None [source]¶
Sets up a log handler to format log messages.
Warning, error, and critical messages will show the level name as a prefix, followed by the message. Debug logs can optionally be enabled as well.
Changed in version 4.1: Added the
debug
argument.- Parameters:
debug (
bool
, optional) –Whether to enable debug logging.
New in version 4.1.
- rbtools.hooks.common.get_review_request_id(regex, commit_message)[source]¶
Returns the review request ID referenced in the commit message.
We assume there is at most one review request associated with each commit. If a matching review request cannot be found, we return 0.
- rbtools.hooks.common.get_review_request(review_request_id, api_root)[source]¶
Returns the review request resource for the given ID.