feat(git): auto-append issue closing keywords to PR body#1044
feat(git): auto-append issue closing keywords to PR body#1044rabanspiegel wants to merge 4 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryAdds an
Confidence Score: 3/5
|
| Filename | Overview |
|---|---|
| src/main/ipc/gitIpc.ts | Integrates injectIssueFooter into git:create-pr and git:merge-to-main handlers. The create-pr integration is clean, but the merge-to-main flow has a behavioral regression: combining --fill with --body-file causes commit-message body content to be dropped in favor of the footer-only content. |
| src/main/lib/prIssueFooter.ts | Well-structured utility with idempotent injection using HTML comment markers. Handles edge cases (undefined body, stale footer replacement, deduplication) correctly. Type narrowing from unknown metadata is defensive and appropriate. |
| src/test/main/prIssueFooter.test.ts | Good test coverage for the footer utility: appending, idempotency, stale replacement, cleanup, and undefined returns. Tests are clear and focused. |
Sequence Diagram
sequenceDiagram
participant Renderer
participant gitIpc as gitIpc.ts
participant DB as DatabaseService
participant Footer as prIssueFooter
participant GH as gh CLI
Note over Renderer,GH: git:create-pr flow
Renderer->>gitIpc: create-pr(taskPath, body, ...)
gitIpc->>DB: getTaskByPath(taskPath)
DB-->>gitIpc: task (with metadata)
gitIpc->>Footer: injectIssueFooter(body, task.metadata)
Footer-->>gitIpc: enriched prBody
gitIpc->>GH: gh pr create --body-file <prBody>
GH-->>gitIpc: PR URL
Note over Renderer,GH: git:merge-to-main flow
Renderer->>gitIpc: merge-to-main(taskPath)
gitIpc->>DB: getTaskByPath(taskPath)
DB-->>gitIpc: task (with metadata)
gitIpc->>Footer: injectIssueFooter(undefined, task.metadata)
Footer-->>gitIpc: footerBody (footer only)
gitIpc->>GH: gh pr create --fill --body-file <footerBody>
Note right of GH: ⚠️ --body-file overrides --fill body
GH-->>gitIpc: PR URL
gitIpc->>GH: gh pr merge --merge
GH-->>gitIpc: merged
Last reviewed commit: 0bcc89f
src/main/ipc/gitIpc.ts
Outdated
| const prCreateArgs = ['pr', 'create', '--fill', '--base', defaultBranch]; | ||
| if (bodyFile) { | ||
| prCreateArgs.push('--body-file', bodyFile); | ||
| } |
There was a problem hiding this comment.
--fill body overridden by --body-file
When --fill is combined with --body-file, the gh CLI uses the commit subject for the title but takes the body exclusively from --body-file, discarding the commit-message body that --fill would have generated. Since footerBody here is only the issue-closing footer (e.g. just Fixes #42), the PR body will lose the commit-message content that --fill previously provided.
Consider reading the --fill-generated body first (e.g. via git log --format=%b) and prepending it to the footer, or appending the footer to the fill-generated content:
| const prCreateArgs = ['pr', 'create', '--fill', '--base', defaultBranch]; | |
| if (bodyFile) { | |
| prCreateArgs.push('--body-file', bodyFile); | |
| } | |
| const prCreateArgs = ['pr', 'create', '--fill', '--base', defaultBranch]; | |
| if (bodyFile) { | |
| prCreateArgs.push('--body-file', bodyFile); | |
| // Note: --body-file overrides --fill's body; title still auto-fills from commits | |
| } |
src/main/ipc/gitIpc.ts
Outdated
| } | ||
| editArgs.push('--body-file', editBodyFile); | ||
| await execFileAsync('gh', editArgs, { cwd: taskPath }); | ||
| outputs.push('gh pr edit --body-file: success'); |
There was a problem hiding this comment.
Dead outputs.push after out already computed
Low Severity
outputs.push('gh pr edit --body-file: success') executes after out has already been computed from the outputs array at the earlier line. The returned output field in the success response is built from out, so this edit-success message is never visible to the caller — it's effectively dead code.
Additional Locations (1)
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.


Summary
injectIssueFooterutility that appendsFixes #<number>/Fixes <LINEAR-ID>lines to PR descriptions based on linked GitHub and Linear issue metadata stored on the taskgit:create-prandgit:merge-to-mainIPC handlers so PRs automatically reference their source issuesChanges
src/main/lib/prIssueFooter.ts(new): Standalone utility withinjectIssueFooter(body, metadata)that builds a marker-delimited footer block from task metadatasrc/main/ipc/gitIpc.ts:git:create-prhandler now looks up the task by path and enriches the PR body with issue footer before submissiongit:merge-to-mainhandler now creates a--body-filewith the issue footer instead of using bare--fill, usingexecFileAsyncfor safer argument handlingsrc/test/main/prIssueFooter.test.ts(new): Tests covering appending, idempotency, stale replacement, and cleanupTest plan
pnpm exec vitest run src/test/main/prIssueFooter.test.tsto verify footer logicFixes #<number>Note
Medium Risk
Touches PR creation/merge automation and GitHub CLI invocation paths; mistakes could result in incorrect PR bodies or failed PR creation/edits, but changes are mostly additive with fallback/error handling and tests for new logic.
Overview
PR creation and merge-to-main flows now automatically enrich PR descriptions with issue-closing footers derived from task metadata (GitHub issue number and/or Linear identifier), using a marker-delimited block to stay idempotent.
git:create-prnow decides between--body-file,--fill, or post-create patching via a newgetCreatePrBodyPlan, and when--fillis used without an explicit body it follows up withgh pr editto append only the footer while preserving the filled body.git:merge-to-mainsimilarly patches the existing/created PR body aftergh pr create --fill, switching toexecFileargument invocation for PR creation and adding best-effort footer patching.Written by Cursor Bugbot for commit 16046d0. This will update automatically on new commits. Configure here.