repomatic.github.sponsor module

Check if a GitHub user is a sponsor of another user or organization.

Uses the GitHub GraphQL API via the gh CLI to query sponsorship data. Supports both user and organization owners, with pagination for accounts that have more than 100 sponsors.

When run in GitHub Actions, the owner defaults to Metadata’s view of the repository; the author and issue/PR number come from the event-payload readers in actions.

repomatic.github.sponsor.get_default_owner()[source]

Get the repository owner from CI context.

Delegates to Metadata.repo_owner.

Return type:

str | None

repomatic.github.sponsor.SPONSORS_QUERY_TEMPLATE = '\nquery($owner: String!, $cursor: String) {\n  %s(login: $owner) {\n    sponsorshipsAsMaintainer(first: 100, after: $cursor, includePrivate: true) {\n      pageInfo { hasNextPage endCursor }\n      nodes { sponsorEntity { ... on User { login } ... on Organization { login } } }\n    }\n  }\n}\n'

GraphQL query for an account’s sponsors, parameterized on the account kind.

The user and organization queries are identical except for the node naming the account (user or organization), which doubles as the response’s data path: _iter_sponsors() interpolates it into both places.

repomatic.github.sponsor.get_sponsors(owner: str) frozenset[str][source]

Get all sponsors for a user or organization.

Tries the user query first, then falls back to organization query.

Results are cached to avoid redundant API calls within the same process.

Parameters:

owner (str) – The GitHub username or organization name.

Return type:

frozenset[str]

Returns:

Frozenset of sponsor login names.

repomatic.github.sponsor.is_sponsor(owner, user)[source]

Check if a user is a sponsor of an owner.

Parameters:
  • owner (str) – The GitHub username or organization to check sponsorship for.

  • user (str) – The GitHub username to check if they are a sponsor.

Return type:

bool

Returns:

True if user is a sponsor of owner, False otherwise.