Skip to main content
// Get commit diff (shows changes from parent)
const commitDiff = await repo.getCommitDiff({
  sha: "abc123def456...",
});

// Get commit diff compared to a specific base
const customDiff = await repo.getCommitDiff({
  sha: "abc123def456...",
  baseSha: "def789abc123...", // optional base commit to compare against
});

// Process file changes
commitDiff.files.forEach((file) => {
  console.log(`${file.state}: ${file.path}`);
  console.log(`Raw status: ${file.rawState}`);
});

// Filter to specific files
const filteredDiff = await repo.getCommitDiff({
  sha: "abc123def456...",
  paths: ["package.json", "src/main.ts"],
});

Options

ParameterTypeDescription
shaRequiredThe commit SHA to get the diff for
baseSha (TypeScript)
base_sha (Python)
OptionalBase commit SHA to compare against. If not specified, compares against the commit’s parent(s)
pathsOptionalArray of file paths to filter the diff. When provided, only returns diffs for the specified files and bypasses size/type filtering

Response

FieldTypeDescription
statsObjectSummary with files, additions, and deletions
filesArrayList of changed files with path, state, rawState, and diff content