GitHubHandler

class baldrick.github.github_api.GitHubHandler(repo, installation=None)

Bases: object

A base class for things that represent things the github app can operate on.

Methods Summary

get_config_value(cfg_key[, cfg_default, branch]) Convenience method to extract user configuration values.
get_file_contents(path_to_file[, branch])
get_repo_config([branch, path_to_file, …]) Load configuration from the repository.
invalidate_cache()
list_statuses(commit_hash) List status messages on a commit on GitHub.
set_status(state, description, context, …) Set status message on a commit on GitHub.

Methods Documentation

get_config_value(cfg_key, cfg_default=None, branch=None)

Convenience method to extract user configuration values.

Values are extracted from the repository configuration, and if not defined, they are extracted from the global app configuration. If this does not exist either, the value is set to the cfg_default argument.

get_file_contents(path_to_file, branch=None)
get_repo_config(branch=None, path_to_file='pyproject.toml', warn_on_failure=True)

Load configuration from the repository.

Parameters:
  • branch (str) – The branch to read the config file from. (Will default to ‘master’)
  • path_to_file (str) – Path to the pyproject.toml file in the repository. Will default to the root of the repository.
  • warn_on_failure (bool) – Emit warning on failure to load the pyproject file.
Returns:

cfg – Configuration parameters.

Return type:

baldrick.config.Config

invalidate_cache()
list_statuses(commit_hash)

List status messages on a commit on GitHub.

Parameters:commit_hash (str) – The commit has to get the statuses for
set_status(state, description, context, commit_hash, target_url=None)

Set status message on a commit on GitHub.

Parameters:
  • state ({ 'pending' | 'success' | 'error' | 'failure' }) – The state to set for the pull request.
  • description (str) – The message that appears in the status line.
  • context (str) – A string used to identify the status line.
  • commit_hash (str) – The commit hash to set the status on.
  • target_url (str or None) – Link to bot comment that is relevant to this status, if given.