Skip to main content

collect_git_commits()

Collect commits, stars, issues, and pull requests for a GitHub user.

Usage

Source

collect_git_commits(
    user,
    emails=None,
    since=None,
    until=None,
    include_forks=False,
    include="commits",
    tz=None
)

Calls the GitHub REST API. Set GITHUB_PAT or GITHUB_TOKEN first: unauthenticated calls are limited to 60 requests an hour, and the search endpoint (issues and PRs) returns at most 1000 results.

Parameters

user: str

GitHub username.

emails: str or list of str = None

Author emails to keep (case insensitive). Applies to commits only.

since: str, datetime.date, or datetime.datetime = None

Bounds. API filters for commits; created_at bounds for issues and PRs.

until: str, datetime.date, or datetime.datetime = None

Bounds. API filters for commits; created_at bounds for issues and PRs.

include_forks: bool = False

Include forked repos (affects commits and stars).

include: str or list of str = "commits"

Any of "commits", "stars", "issues", "prs".

tz: str = None
Time zone for the local time columns. Defaults to the system zone.

Returns

polars.DataFrame or dict of polars.DataFrame

With the default include="commits", one row per commit with columns repo, sha, timestamp, author_name, author_email, message, local_ts, date, hour, weekday, and year. Otherwise a dict keyed by type:

  • stars: the user’s own repos with stargazers_count, forks_count, watchers_count, language, description, created_at, updated_at.
  • issues, prs: items authored by the user across GitHub, with repo (owner/name), number, title, state, created_at, closed_at, url.

Examples

>>> commits = collect_git_commits(
...     "mjfrigaard", emails="you@example.com"
... )  # doctest: +SKIP
>>> stats = collect_git_commits(
...     "mjfrigaard", include=["commits", "stars", "issues", "prs"]
... )  # doctest: +SKIP