Skip to content

feat(#1575): populate PR body from target repo's PR template#2122

Open
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/1575-pr-template-support
Open

feat(#1575): populate PR body from target repo's PR template#2122
fullsend-ai-coder[bot] wants to merge 1 commit into
mainfrom
agent/1575-pr-template-support

Conversation

@fullsend-ai-coder

Copy link
Copy Markdown
Contributor

When creating PRs, post-code.sh now checks for .github/PULL_REQUEST_TEMPLATE.md (and other GitHub-supported locations) in the target repo. If found, the template's sections are populated with context from the agent's commit:

  • Description/Summary sections: filled with the commit body
  • Type of change sections: filled with the conventional commit
    type (fix, feat, etc.)
  • How to test sections: links to the originating issue
  • Related issues sections: references the issue number
  • Screenshots sections: marked N/A
  • Unrecognized sections: preserved as-is from the template
  • Checkbox items in filled sections: preserved for reviewers

HTML comments (author instructions) are stripped. Templates without markdown headers get the description prepended. When no template exists, the existing freeform format is used as a fallback.

Added 20 test cases covering section filling, HTML comment stripping, checkbox preservation, unrecognized section passthrough, headerless templates, and full body assembly with and without templates.

Note: pre-commit could not run in the sandbox due to Go module cache permission errors (sandbox infrastructure issue, not related to these shell script changes). The post-script runs authoritative pre-commit on the CI runner.


Closes #1575

Post-script verification

  • Branch is not main/master (agent/1575-pr-template-support)
  • Secret scan passed (gitleaks — 1281fa9973718b519e2a2404f247cf26baf6521f..HEAD)
  • Pre-commit hooks passed (authoritative run on runner)
  • Tests ran inside sandbox

When creating PRs, post-code.sh now checks for
.github/PULL_REQUEST_TEMPLATE.md (and other GitHub-supported
locations) in the target repo. If found, the template's
sections are populated with context from the agent's commit:

- Description/Summary sections: filled with the commit body
- Type of change sections: filled with the conventional commit
  type (fix, feat, etc.)
- How to test sections: links to the originating issue
- Related issues sections: references the issue number
- Screenshots sections: marked N/A
- Unrecognized sections: preserved as-is from the template
- Checkbox items in filled sections: preserved for reviewers

HTML comments (author instructions) are stripped. Templates
without markdown headers get the description prepended. When
no template exists, the existing freeform format is used as a
fallback.

Added 20 test cases covering section filling, HTML comment
stripping, checkbox preservation, unrecognized section
passthrough, headerless templates, and full body assembly
with and without templates.

Note: pre-commit could not run in the sandbox due to Go
module cache permission errors (sandbox infrastructure
issue, not related to these shell script changes). The
post-script runs authoritative pre-commit on the CI runner.

Closes #1575
@github-actions

Copy link
Copy Markdown

Site preview

Preview: https://af883d15-site.fullsend-ai.workers.dev

Commit: 80963c8606babd9b84aeb6a1470789a1b6934c09

@fullsend-ai-review

fullsend-ai-review Bot commented Jun 10, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 1:43 PM UTC · Completed 1:55 PM UTC
Commit: 4ed6da4 · View workflow run →

@fullsend-ai-review

Copy link
Copy Markdown

Review

Findings

Low

  • [edge-case] internal/scaffold/fullsend-repo/scripts/post-code.sh:465COMMIT_TYPE extraction with grep -oE '^[a-z]+' matches any leading lowercase word, not just valid conventional commit types. A non-conventional subject like "add new feature" would extract "add", producing "This is a add change." — grammatically awkward and semantically misleading. In practice, the pipeline consistently generates conventional commit subjects, so the risk is low.
    Remediation: Consider validating COMMIT_TYPE against a known list (fix|feat|chore|docs|refactor|test|ci|build|perf|style|revert) and falling back to "change" if it doesn't match.

  • [test-adequacy] internal/scaffold/fullsend-repo/scripts/post-code-test.sh:625 — The test helper populate_pr_template is a full copy-paste of the production function. If either copy is updated independently, tests will pass against stale logic. No mechanism (sourcing, hash-check comment) detects drift between the two copies.

  • [edge-case] internal/scaffold/fullsend-repo/scripts/post-code.sh:351 — Header detection regex ^#{1,3}[[:space:]] only matches h1–h3. PR templates using h4+ headers for sub-sections under a recognized section will have those sub-sections silently dropped when skip_body is true.

  • [test-adequacy] internal/scaffold/fullsend-repo/scripts/post-code-test.sh:625 — No test covers the COMMIT_TYPE extraction logic. The build_pr_body_with_template test helper accepts commit_type as a parameter, bypassing the grep extraction.

  • [edge-case-handling] internal/scaffold/fullsend-repo/scripts/post-code.sh — GitHub supports template selection via subdirectories (.github/PULL_REQUEST_TEMPLATE/). The implementation picks the first match from default locations but doesn't handle template directories. Worth documenting as a known limitation.

Info

@@ -376,9 +463,27 @@ else
DESCRIPTION="${COMMIT_BODY}"
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] edge-case

COMMIT_TYPE extraction with grep -oE '^[a-z]+' matches any leading lowercase word, not just valid conventional commit types. A non-conventional subject would produce misleading output in the Type of change template section.

Suggested fix: Validate COMMIT_TYPE against a known list (fix|feat|chore|docs|refactor|test|ci|build|perf|style|revert) and fall back to 'change' if it doesn't match.

# Test helper — reimplements the PR template population logic from
# post-code.sh so we can test it without a git repo or network access.
# ---------------------------------------------------------------------------
populate_pr_template() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] test-adequacy

The test helper populate_pr_template is a full copy-paste of the production function. If either copy is updated independently, tests will pass against stale logic with no mechanism to detect drift.

printf '%s\n\n%s\n' "${description}" "${clean}"
return
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] edge-case

Header detection regex ^#{1,3}[[:space:]] only matches h1-h3. H4+ sub-sections under a recognized section will be silently dropped when skip_body is true.

# Test helper — reimplements the PR template population logic from
# post-code.sh so we can test it without a git repo or network access.
# ---------------------------------------------------------------------------
populate_pr_template() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[low] test-adequacy

No test covers the COMMIT_TYPE extraction logic (grep -oE '^[a-z]+'). The build_pr_body_with_template test helper accepts commit_type as a parameter, bypassing the extraction.

@fullsend-ai-review fullsend-ai-review Bot added the ready-for-merge All reviewers approved — ready to merge label Jun 10, 2026
@rh-hemartin rh-hemartin self-assigned this Jun 15, 2026
@rh-hemartin

Copy link
Copy Markdown
Member

/fs-fix rebase

@fullsend-ai-coder

fullsend-ai-coder Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Finished Fix · ❌ Failure · Started 8:18 AM UTC · Completed 8:26 AM UTC
Commit: 4e21a60 · View workflow run →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-merge All reviewers approved — ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code agent should follow the target repo's PR template

1 participant