refactor: use git cat-file blob instead of git show in readBlobAsBase64#26349
refactor: use git cat-file blob instead of git show in readBlobAsBase64#26349
Conversation
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/399a3c88-0473-46c9-b47e-197bd513dccb Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/399a3c88-0473-46c9-b47e-197bd513dccb Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Refactors readBlobAsBase64 in the signed-commit replay helper to read blob content directly by object hash (from git diff-tree --raw) instead of using git show <sha>:<path>.
Changes:
- Update
readBlobAsBase64to accept(blobHash, cwd)and usegit cat-file blob <blobHash>. - Extract
dstHashfrom raw diff fields and pass it through rename/copy/add-modify paths. - Add a new repo-level
.mcp.jsonMCP server configuration file.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/push_signed_commits.cjs | Switch blob reading to git cat-file blob <dstHash> and update helper signature + call sites. |
| .mcp.json | Adds MCP server configuration pointing at gh aw mcp-server. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 2
| * Read a blob object as a base64-encoded string using `git cat-file blob | ||
| * <blobHash>`. The raw bytes emitted by git are collected via the | ||
| * `exec.exec` stdout listener so that binary files are not corrupted by any | ||
| * UTF-8 decoding layer (unlike `exec.getExecOutput` which always passes | ||
| * stdout through a `StringDecoder('utf8')`). |
There was a problem hiding this comment.
The JSDoc inline code for the git command is split across lines, so the backticked snippet ends at git cat-file blob and <blobHash> is no longer part of the code span. This renders oddly and makes the command example ambiguous; consider keeping it as a single inline code span (e.g., git cat-file blob <blobHash>) or use a fenced code block in the comment text.
| * Read a blob object as a base64-encoded string using `git cat-file blob | |
| * <blobHash>`. The raw bytes emitted by git are collected via the | |
| * `exec.exec` stdout listener so that binary files are not corrupted by any | |
| * UTF-8 decoding layer (unlike `exec.getExecOutput` which always passes | |
| * stdout through a `StringDecoder('utf8')`). | |
| * Read a blob object as a base64-encoded string using `git cat-file blob <blobHash>`. | |
| * The raw bytes emitted by git are collected via the `exec.exec` stdout | |
| * listener so that binary files are not corrupted by any UTF-8 decoding | |
| * layer (unlike `exec.getExecOutput` which always passes stdout through a | |
| * `StringDecoder('utf8')`). |
| { | ||
| "servers": { | ||
| "github-agentic-workflows": { | ||
| "command": "gh", | ||
| "args": [ | ||
| "aw", | ||
| "mcp-server" | ||
| ] | ||
| } | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
This PR’s title/description is focused on refactoring readBlobAsBase64, but this adds a new .mcp.json MCP server configuration file. If this file was generated incidentally (e.g., by running gh aw init), it should be removed from this PR or called out explicitly in the description so reviewers understand the intent and impact of adding a repo-level tool configuration.
There was a problem hiding this comment.
Agreed — the .mcp.json file looks like it was incidentally generated and should be called out or removed. Good catch!
📰 BREAKING: Report filed by Smoke Copilot · ● 756K
|
@copilot review all comments |
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/1d42345b-7c51-488d-8742-525aea3c0abd Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing... |
|
✅ All tools validated successfully! Agent Container Smoke Test confirms agent container is ready. |
|
✨ The prophecy is fulfilled... Smoke Codex has completed its mystical journey. The stars align. 🌟 |
|
🎬 THE END — Smoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨ |
|
|
Agent Container Tool Check
Result: 12/12 tools available ✅ Overall Status: PASS
|
|
Smoke test (Codex) for run 24433538575: FAIL Merged PRs:
Results: GitHub MCP ✅, Serena activate ✅, Serena find_symbol ❌, Playwright ✅, web-fetch ❌, file write/read ✅, build ✅ Warning
|
|
🤖 Smoke Test Results — Run §24433538576\n\n| Test | Status |\n|------|--------|\n| GitHub MCP | ✅ |\n| MCP Scripts GH CLI | ✅ |\n| Serena MCP | ✅ |\n| Playwright | ✅ |\n| Web Fetch | ✅ |\n| File Writing | ✅ |\n| Bash Tool | ✅ |\n| Discussion Interaction | ✅ |\n| Build gh-aw | ✅ |\n| Upload artifact | ✅ |\n| Create Discussion | ✅ |\n| Workflow Dispatch | ✅ |\n| PR Review | ✅ |\n\nOverall: ✅ PASS\n\nPR by
|
There was a problem hiding this comment.
Clean refactor — the simplified readBlobAsBase64(blobHash, cwd) signature is more focused and direct. Using git cat-file blob over git show sha:path removes path-resolution indirection and aligns with how the blob hash is already available from git diff-tree --raw.
📰 BREAKING: Report filed by Smoke Copilot · ● 756K
| await exec.exec("git", ["cat-file", "blob", blobHash], { | ||
| cwd, | ||
| silent: true, | ||
| listeners: { |
There was a problem hiding this comment.
Nice simplification! By accepting blobHash directly instead of (sha, filePath), this function now does exactly one thing: reads a blob by its object hash. This is more robust since it avoids any path resolution ambiguity.
| } | ||
| const srcMode = modeFields[0]; // source file mode (e.g. 100644, 100755, 120000, 160000) | ||
| const dstMode = modeFields[1]; // destination file mode (e.g. 100644, 100755, 120000, 160000) | ||
| const dstHash = modeFields[3]; // destination blob hash (object ID of the file in this commit) |
There was a problem hiding this comment.
Good extraction of dstHash from modeFields[3] — it's already available from the git diff-tree --raw output and reusing it avoids the need to compose sha:filePath strings at the call sites.
|
📰 VERDICT: Smoke Copilot has concluded. All systems operational. This is a developing story. 🎤 |
|
Commit pushed:
|
Smoke Test: Claude — Run §24433538607Overall: PARTIAL (1 failed, 2 skipped)
|
There was a problem hiding this comment.
💥 Automated smoke test review - all systems nominal!
💥 [THE END] — Illustrated by Smoke Claude · ● 191.9K
| * @param {string} blobHash - Object hash of the blob (from `git diff-tree --raw` dstHash field) | ||
| * @param {string} cwd - Working directory of the local git checkout | ||
| * @returns {Promise<string>} Base64-encoded file contents | ||
| */ |
There was a problem hiding this comment.
✅ Clean refactor: using blobHash directly instead of sha + filePath is more precise and avoids potential path-quoting issues. The function signature change is clear and well-documented.
| } | ||
| const srcMode = modeFields[0]; // source file mode (e.g. 100644, 100755, 120000, 160000) | ||
| const dstMode = modeFields[1]; // destination file mode (e.g. 100644, 100755, 120000, 160000) | ||
| const dstHash = modeFields[3]; // destination blob hash (object ID of the file in this commit) |
There was a problem hiding this comment.
Good addition of dstHash from modeFields[3]. This aligns with the git diff-tree --raw output format and makes the blob hash available for the refactored readBlobAsBase64 call below.
Implements the reviewer suggestion from #26287: since the destination blob hash (
dstHash) is already available from thegit diff-tree -r --rawoutput introduced in #26259, there's no need to compose<sha>:<filePath>forgit show. Usinggit cat-file blob <dstHash>directly is simpler (one argument instead of two) and more robust (direct object lookup by hash, no path resolution involved).Changes
readBlobAsBase64: Signature changed from(sha, filePath, cwd)to(blobHash, cwd). Usesgit cat-file blob <blobHash>instead ofgit show <sha>:<filePath>.dstHashfrommodeFields[3](already guarded by the existingmodeFields.length < 5check).dstHashinstead ofsha, filePath.Changeset
git cat-file blob <hash>instead ofgit show <sha>:<path>when reading destination blobs in signed commit push operations, improving robustness and simplifying blob lookup.Warning
The following domains were blocked by the firewall during workflow execution:
ab.chatgpt.comchatgpt.cominvalid.example.invalidTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
✨ PR Review Safe Output Test - Run 24433538607