Skip to content

feat: add include_patch parameter to get_commit tool#1924

Merged
SamMorrowDrums merged 1 commit into
github:mainfrom
voki-gandzhelashvili-t:feature/add-patch-to-commit-files
Jun 1, 2026
Merged

feat: add include_patch parameter to get_commit tool#1924
SamMorrowDrums merged 1 commit into
github:mainfrom
voki-gandzhelashvili-t:feature/add-patch-to-commit-files

Conversation

@voki-gandzhelashvili-t
Copy link
Copy Markdown

@voki-gandzhelashvili-t voki-gandzhelashvili-t commented Jan 29, 2026

Summary

This PR adds a new optional parameter include_patch to the get_commit tool, allowing users to optionally include the patch/diff content for each file in the response.

Key Design Decision: Opt-in Behavior

The patch content is not included by default (include_patch: false). This is intentional:

  • Non-breaking change: Existing integrations continue to work unchanged
  • Performance conscious: Patch content can be large and may not always be needed
  • Explicit control: Users opt-in when they need the actual diff content

Changes

  1. Added Patch string field to MinimalCommitFile struct
  2. Added include_patch boolean parameter to get_commit tool (default: false)
  3. Updated convertToMinimalCommit function to conditionally include patch content

Usage

// Get commit without patch (default behavior, unchanged)
get_commit(owner: "foo", repo: "bar", sha: "abc123")

// Get commit with patch content
get_commit(owner: "foo", repo: "bar", sha: "abc123", include_patch: true)

Example Response with include_patch: true

{
  "sha": "abc123...",
  "files": [{
    "filename": "src/example.go",
    "status": "modified",
    "additions": 5,
    "deletions": 2,
    "changes": 7,
    "patch": "@@ -10,6 +10,9 @@\n func example() {\n+    // new code\n+    return true\n }"
  }]
}

Use Cases

  • Code review automation tools
  • AI agents analyzing code changes
  • Commit analysis and auditing tools
  • Any consumer that needs to see what actually changed in a commit

Test Plan

  • Code compiles successfully
  • Existing tests pass
  • Manual testing confirms:
    • Default behavior unchanged (no patch in response)
    • `include_patch: true` includes patch content

@voki-gandzhelashvili-t voki-gandzhelashvili-t requested a review from a team as a code owner January 29, 2026 09:29
@voki-gandzhelashvili-t voki-gandzhelashvili-t force-pushed the feature/add-patch-to-commit-files branch from df0c3db to 5d9c352 Compare January 29, 2026 09:35
@voki-gandzhelashvili-t voki-gandzhelashvili-t changed the title feat: add patch field to MinimalCommitFile feat: add include_patch parameter to get_commit tool Jan 29, 2026
@SamMorrowDrums SamMorrowDrums force-pushed the feature/add-patch-to-commit-files branch 2 times, most recently from af67c6c to f34baee Compare June 1, 2026 10:03
Replace the get_commit tool's two boolean flags (include_diff,
include_patch) with a single detail enum: none / stats / full_patch.

Why:
- The two-boolean shape had an awkward dependency
  ("include_patch only applies when include_diff is true") and an
  impossible state (include_patch=true, include_diff=false) that was
  silently ignored.
- A single discriminator collapses three meaningful response shapes
  into one orthogonal choice, makes the most expensive option
  ("full_patch") self-describing, and eliminates the "diff vs patch"
  naming confusion.

Behavior:
- Default ("stats") matches the previous default
  (include_diff=true, include_patch=false): per-file metadata with no
  patch text. Existing callers using defaults are unaffected.
- "none" omits Stats and Files entirely (was include_diff=false).
- "full_patch" is the new opt-in level that adds the unified diff to
  each MinimalCommitFile.

Breaking change: callers that previously passed include_diff or
include_patch must switch to detail. Callers using the defaults are
unaffected.

Changes:
- Added Patch field to MinimalCommitFile.
- Added commitDetail type, parseCommitDetail, and migrated
  convertToMinimalCommit to take a commitDetail.
- Updated get_commit schema, list_commits caller (commitDetailNone),
  unit tests, toolsnap, and README.

Co-authored-by: Sam Morrow <sammorrowdrums@github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@SamMorrowDrums SamMorrowDrums force-pushed the feature/add-patch-to-commit-files branch from f34baee to af53280 Compare June 1, 2026 10:11
@SamMorrowDrums SamMorrowDrums merged commit 7e79ae9 into github:main Jun 1, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants