Class CommitResource

Represents a GitHub commit resource with chainable async methods.

Implements PromiseLike<GitHubCommit> so it can be awaited directly to fetch the commit info, while also exposing sub-resource methods.

// Await directly to get commit info (includes stats and files)
const commit = await gh.org('github').repo('linguist').commit('abc123');

// Get CI/CD statuses for this commit
const statuses = await gh.org('github').repo('linguist').commit('abc123').statuses();

// Get the combined (aggregated) status
const combined = await gh.org('github').repo('linguist').commit('abc123').combinedStatus();

// Get GitHub Actions check runs
const checks = await gh.org('github').repo('linguist').commit('abc123').checkRuns();

Implements

Methods

  • Adds a comment to this commit.

    POST /repos/{owner}/{repo}/commits/{commit_sha}/comments

    Parameters

    • data: CommitCommentData

      Comment data. body is required.

    • Optionalsignal: AbortSignal

    Returns Promise<GitHubCommitComment>

    The created commit comment

  • Creates a commit status (e.g., from a CI/CD system).

    POST /repos/{owner}/{repo}/statuses/{sha}

    Parameters

    • data: CreateStatusData

      Status data. state is required.

    • Optionalsignal: AbortSignal

    Returns Promise<GitHubCommitStatus>

    The created commit status

  • Fetches the commit details, including stats and changed files.

    GET /repos/{owner}/{repo}/commits/{ref}

    Parameters

    • Optionalsignal: AbortSignal

    Returns Promise<GitHubCommit>

    The commit object with stats and files