Skip to content

feat: PR description draft from config and forge templates - #76

Merged
hokwangchoi merged 1 commit into
hokwangchoi:masterfrom
simtel12:pgit/gregorios-leach/feat--pr-description-draft-from-config-and-forge-t
May 5, 2026
Merged

feat: PR description draft from config and forge templates#76
hokwangchoi merged 1 commit into
hokwangchoi:masterfrom
simtel12:pgit/gregorios-leach/feat--pr-description-draft-from-config-and-forge-t

Conversation

@simtel12

@simtel12 simtel12 commented May 1, 2026

Copy link
Copy Markdown

Summary

This change seeds the PR/MR description editor with smarter defaults instead of a single hard-coded outline.

Precedence (first match wins):

  1. [repo].pr_description_template in .pilegit.toml — path (relative to repo root) to a markdown file. If the file exists and is non-empty, its contents seed the editor. The placeholder {{subject}} is replaced with the commit title when present in the template.
  2. Forge-specific templatesGitHub looks for the usual PR template locations (e.g. .github/pull_request_template.md and the other documented single-file paths). GitLab reads .gitlab/merge_request_templates/*.md, preferring Default.md when present, then other files in sorted order.
  3. Built-in fallback — a short outline with Description and Test Plan sections and the commit title under Description.

The submit flow in the TUI now calls forge::pr_description::compose_initial_draft with the current forge, repo config, and subject. Config loading for the TUI entry path uses Config::load_or_default so default [repo] fields (including the new option) are applied consistently.

Forge traitpr_description_draft_hint is the extension point for per-forge discovery; only GitHub and GitLab implement it today; other forges use config + built-in.

Test plan

  • cargo test — includes unit tests in src/forge/pr_description.rs (GitHub template path, config overrides forge, built-in fallback).
  • Config template: add pr_description_template = "path/to.md" under [repo] in .pilegit.toml, put {{subject}} in the file, run submit for a patch and confirm the temp editor file contains the substituted title.
  • GitHub: in a repo with .github/pull_request_template.md, submit (or the code path that opens the description editor) and confirm the template body appears when pr_description_template is unset.
  • GitLab: with .gitlab/merge_request_templates/Default.md (or another .md in that directory), confirm the same when using GitLab forge type.
  • No templates: empty/minimal repo with no config template — confirm the built-in Description / Test Plan draft still appears with the commit subject.

@hokwangchoi

Copy link
Copy Markdown
Owner

Please fix clippy. Thank you!

@gregorios-leach-ck

Copy link
Copy Markdown
Contributor

| Please fix clippy.

Fixed!

Add pr_description module, RepoConfig template path, load_or_default, and
forge-specific draft hints. TUI uses composed draft when opening the
submit editor instead of a hardcoded markdown stub.

Made-with: Cursor
@simtel12
simtel12 force-pushed the pgit/gregorios-leach/feat--pr-description-draft-from-config-and-forge-t branch from 0f14e72 to 7c6392c Compare May 4, 2026 17:03
@hokwangchoi
hokwangchoi merged commit a9fc975 into hokwangchoi:master May 5, 2026
1 check passed
@simtel12
simtel12 deleted the pgit/gregorios-leach/feat--pr-description-draft-from-config-and-forge-t branch May 5, 2026 00:28
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.

3 participants