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

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

Conversation

@voki-gandzhelashvili-t

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

Copy link
Copy Markdown

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
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
github-mcp-server 1.2.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## What's Changed
* MCP Apps: align with the 2026-01-26 stable spec by @mattdholloway in github/github-mcp-server#2573
* feat: add create_project and create_iteration_field methods to projects_write by @SamMorrowDrums in github/github-mcp-server#2232
* fix: restore thread id in get_review_comments response by @omid-ant in github/github-mcp-server#2245
* docs: add installation guides for Zed and OpenCode by @jluocsa in github/github-mcp-server#2535
* docs: improve Claude installation guide with Windows PowerShell support by @vincent067 in github/github-mcp-server#2312
* Fix remote-server docs inconsistency regarding toolset at base url by @korobitsin in github/github-mcp-server#2217
* fix: return project item id usable for updates by @njoppi2 in github/github-mcp-server#2169
* fix: add MCP initialize handshake to mcpcurl by @ra-n-dom in github/github-mcp-server#2009
* fix: support team pull request reviewers by @he-yufeng in github/github-mcp-server#2514
* Skip MCP App form when issue/PR write carries non-form params by @mattdholloway in github/github-mcp-server#2589
* feat: add include_patch parameter to get_commit tool by @voki-gandzhelashvili-t in github/github-mcp-server#1924
* MCP Apps: Open created issue/PR link via host open-link capability by @mattdholloway in github/github-mcp-server#2593
* fix: Empty assignees array should clear assignees by @RossTarrant in github/github-mcp-server#2600
* Add confidence parameter to issue mutation MCP tools by @alondahari in github/github-mcp-server#2605

## New Contributors
* @omid-ant made their first contribution in github/github-mcp-server#2245
* @vincent067 made their first contribution in github/github-mcp-server#2312
* @korobitsin made their first contribution in github/github-mcp-server#2217
* @njoppi2 made their first contribution in github/github-mcp-server#2169
* @ra-n-dom made their first contribution in github/github-mcp-server#2009
* @he-yufeng made their first contribution in github/github-mcp-server#2514
* @voki-gandzhelashvili-t made their first contribution in github/github-mcp-server#1924

**Full Changelog**: https://github.com/github/github-mcp-server/compare/v1.1.2...v1.2.0</pre>
  <p>View the full release notes at <a href="https://github.com/github/github-mcp-server/releases/tag/v1.2.0">https://github.com/github/github-mcp-server/releases/tag/v1.2.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!11013
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