saltext.github.utils.gh.repos

Operations on GitHub repositories. Repository listing and creation are organization-scoped, everything else works on any owner’s repositories.

saltext.github.utils.gh.repos.to_dict(repo)[source]

Render a PyGithub Repository object into a plain dictionary, excluding GitHub’s deprecated alias fields (watchers_count, watchers, forks, open_issues).

saltext.github.utils.gh.repos.list_all(conn, *, owner=None, ignore_cache=False)[source]

Return all repositories of an owner as PyGithub Repository objects (cached).

conn

GitHubConnection to use.

owner

Owner whose repositories to list. Defaults to the connection’s owner. Private repositories of users other than the authenticated one are not visible.

ignore_cache

Bypass the cached repository list.

saltext.github.utils.gh.repos.get_info(conn, name, *, owner=None, ignore_cache=False)[source]

Return information about a single repository as a dictionary (cached).

conn

GitHubConnection to use.

name

Repository name.

owner

Owner of the repository. Defaults to the connection’s owner.

ignore_cache

Bypass the cached repository information.

Raises GitHubNotFoundError if the repository does not exist.

saltext.github.utils.gh.repos.get_file_content(conn, name, path, *, owner=None, ignore_cache=False)[source]

Return the decoded text content of a repository file via the contents API, or None when the file is missing or unusable (not a regular file, too large for the API to carry inline, not valid UTF-8). Results are cached, including negative ones – also persistently when the connection carries a store, validated against the repository’s pushed_at timestamp.

conn

GitHubConnection to use.

name

Repository name.

path

Path of the file inside the repository.

owner

Owner of the repository. Defaults to the connection’s owner.

ignore_cache

Bypass the cached file content.

saltext.github.utils.gh.repos.clear_file_cache(conn, name, *, owner=None)[source]

Drop all cached file contents of one repository, including cached negative lookups and persistently stored ones.

conn

GitHubConnection to use.

name

Repository name.

owner

Owner of the repository. Defaults to the connection’s owner.

saltext.github.utils.gh.repos.get_teams(conn, name, *, owner=None)[source]

Return the teams a repository belongs to.

conn

GitHubConnection to use.

name

Repository name.

owner

Owner of the repository. Defaults to the connection’s owner.

Raises GitHubNotFoundError if the repository does not exist.

saltext.github.utils.gh.repos.create(conn, name, *, owner=None, description=None, homepage=None, private=None, has_issues=None, has_wiki=None, has_downloads=None, auto_init=None, gitignore_template=None, license_template=None)[source]

Create a new repository and wait for it to become visible.

conn

GitHubConnection to use.

name

Repository name to create.

owner

Owner to create the repository for. Defaults to the connection’s owner. The GitHub API only supports creating repositories for organizations and the authenticated user.

description

Repository description.

homepage

URL with more information about the repository, e.g. rendered docs.

private

Repository visibility.

has_issues

Enable issues for this repository.

has_wiki

Enable the wiki for this repository.

has_downloads

Enable downloads for this repository.

auto_init

Create an initial commit with an empty README.

gitignore_template

Desired language or platform for a .gitignore, e.g. “Haskell”.

license_template

Desired LICENSE template to apply, e.g. “mit” or “mozilla”.

saltext.github.utils.gh.repos.update(conn, name, *, owner=None, description=None, homepage=None, private=None, has_issues=None, has_wiki=None, has_downloads=None, default_branch=None, allow_privacy_change=False)[source]

Update an existing repository.

conn

GitHubConnection to use.

name

Repository name to update.

owner

Owner of the repository. Defaults to the connection’s owner.

description

Repository description.

homepage

URL with more information about the repository, e.g. rendered docs.

private

Repository visibility. Changing this requires allow_repo_privacy_changes to be enabled in the profile.

has_issues

Enable issues for this repository.

has_wiki

Enable the wiki for this repository.

has_downloads

Enable downloads for this repository.

default_branch

Default branch of the repository. Must already exist: Ignored during repo creation.

allow_privacy_change

Allow changing the repository’s visibility. Defaults to false.

saltext.github.utils.gh.repos.delete(conn, name, *, owner=None)[source]

Delete a repository.

conn

GitHubConnection to use.

name

Repository name to delete.

owner

Owner of the repository. Defaults to the connection’s owner.