Skip to content

fix(dev-workflow): prepend Closes #N to PR body for auto-closing issues - #219

Merged
NTCoding merged 1 commit into
mainfrom
fix-pr-message-link
Jan 28, 2026
Merged

NTCoding merged 1 commit into
mainfrom
fix-pr-message-link

Conversation

@NTCoding

@NTCoding NTCoding commented Jan 28, 2026 •

Copy link
Copy Markdown
Owner

Lost during shell-to-TypeScript migration of submit-pr.sh.

Summary by CodeRabbit

Release Notes

✏️ Tip: You can customize this high-level summary in your review settings.

Lost during shell-to-TypeScript migration of submit-pr.sh.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@qodo-code-review

Copy link
Copy Markdown
Contributor
ⓘ Your approaching your monthly quota for Qodo. Upgrade your plan

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Possible Issue

rawBody can be undefined when neither --pr-body nor taskDetails?.body is provided. In that case, when issueNumber is set, the template literal will produce a PR body containing the string undefined, and the subsequent !prTitle || !prBody check will not catch it because the resulting string is truthy. Consider validating rawBody before interpolation (or defaulting to an empty string only if that’s acceptable) and add a test to prevent regressions.

const rawBody = cliPrBody ?? taskDetails?.body
const prBody = issueNumber ? `Closes #${issueNumber}\n\n${rawBody}` : rawBody
const commitMessage = cliCommitMessage

if (!prTitle || !prBody) {
  throw new MissingPullRequestDetailsError()
Test Coverage

The updated expectation covers the common path, but it would be valuable to add cases for when --pr-body is provided (ensuring it also gets the Closes #N prefix when issueNumber exists), and when no body is available (ensuring an error is thrown rather than producing an undefined body string).

expect(result.prBody).toStrictEqual('Closes #123\n\nTask body')
expect(result.hasIssue).toStrictEqual(true)

@coderabbitai

coderabbitai Bot commented Jan 28, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The changes add automatic issue closing references to PR bodies. When an issue number is provided, the PR body is prepended with Closes #<issueNumber>\n\n followed by the original body content. Both implementation and test files are updated to reflect this behavior.

Changes

Cohort / File(s) Summary
PR Body Construction Logic
tools/dev-workflow/features/complete-task/domain/pull-request-draft.ts
Introduces an intermediary rawBody variable and conditionally prepends a closing issue reference (Closes #<issueNumber>\n\n) to the PR body when an issue number exists.
Test Expectations
tools/dev-workflow/features/complete-task/domain/pull-request-draft.spec.ts
Updates test assertion to expect the new PR body format that includes the closing issue reference.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

Review effort 2/5

Poem

🐰 PR bodies now skip ahead with glee,
"Closes #123" for all to see,
Each issue reference finds its place,
The bunny's code runs with grace! ✨

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(dev-workflow): prepend Closes #N to PR body for auto-closing issues' directly and clearly summarizes the main change: prepending a closing reference to the PR body to enable auto-closing of issues.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying living-architecture with  Cloudflare Pages  Cloudflare Pages

Latest commit: a477415
Status: ✅  Deploy successful!
Preview URL: https://4b1d9f5e.living-architecture.pages.dev
Branch Preview URL: https://fix-pr-message-link.living-architecture.pages.dev

View logs

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tools/dev-workflow/features/complete-task/domain/pull-request-draft.ts (1)

45-50: Bug: PR body can contain literal "undefined" when rawBody is missing.

When issueNumber is provided but both cliPrBody and taskDetails?.body are undefined, rawBody is undefined. The template literal at line 46 produces "Closes #123\n\nundefined" (the literal string "undefined"), which is truthy and passes the validation at line 49.

🐛 Proposed fix: validate rawBody before constructing prBody
   const prTitle = cliPrTitle ?? taskDetails?.title
   const rawBody = cliPrBody ?? taskDetails?.body
-  const prBody = issueNumber ? `Closes #${issueNumber}\n\n${rawBody}` : rawBody
   const commitMessage = cliCommitMessage

-  if (!prTitle || !prBody) {
+  if (!prTitle || !rawBody) {
     throw new MissingPullRequestDetailsError()
   }

+  const prBody = issueNumber ? `Closes #${issueNumber}\n\n${rawBody}` : rawBody
+
   if (!commitMessage) {

@NTCoding
NTCoding merged commit 3c8062a into main Jan 28, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant