GitHubHandler

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

Bases: object

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

Attributes Summary

default_branch

repo_info

The return of GET /repos/{org}/{repo}

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_checks(commit_hash[, only_ours])

List check messages on a commit on GitHub.

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.

Attributes Documentation

default_branch
repo_info

The return of GET /repos/{org}/{repo}

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')

Load configuration from the repository.

Parameters
  • branch (str) – The branch to read the config file from. (Will default to the default branch)

  • path_to_file (str) – Path to the pyproject.toml file in the repository. Will default to the root of the repository.

Returns

cfg – Configuration parameters.

Return type

baldrick.config.Config

invalidate_cache()
list_checks(commit_hash, only_ours=True)

List check messages on a commit on GitHub.

Parameters
  • commit_hash (str) – The commit has to get the statuses for

  • only_ours (bool, optional) – Only return status that this app has posted.

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.