rbtools.hooks.common¶
Common functionality for working with repository hooks.
Functions
  | 
Closes the specified review request as submitted.  | 
  | 
Executes the specified command and returns 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 theRBClientconstructor. SeeSyncTransport.__init__()for arguments that are accepted.
- Returns:
 This returns a 2-tuple of the
RBClientand<root resource> rbtools.api.resource.Resource.- Return type:
 
- rbtools.hooks.common.execute(command)[source]¶
 Executes the specified command and returns the stdout output.
- 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
debugargument.- 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.