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, with pagination for accounts that have more than 100 sponsors.

repomatic.github.sponsor.SPONSORS_QUERY = '\nquery($owner: String!, $cursor: String) {\n  repositoryOwner(login: $owner) {\n    ... on Sponsorable {\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}\n'¶

GraphQL query for an account’s sponsors, a user or an organization alike.

repositoryOwner resolves both kinds of account, and both implement the Sponsorable interface, so one query covers either without a probe for the kind first.

repomatic.github.sponsor.iter_sponsors(owner)[source]¶

Iterate over every sponsor of owner, following pagination.

Parameters:

owner (str) – The user or organization to query.

Yields:

str – Login names of sponsors.

Raises:

GhCommandError – When a gh invocation fails.

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

Check if a user is a sponsor of an owner.

A failed query reads as “not a sponsor”: the label it gates is a convenience, so an API outage must not fail the job that asks.

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.