Derive PR title and body from commits with --fill / --fill-first #174

Merged
stephen merged 1 commit from feat/165-pr-create-fill into main 2026-06-15 15:40:40 +00:00
Owner

Closes #165.

fj pr create made you retype a title and body the branch's commits already carry. --fill derives both from git log base..head and --fill-first uses only the first commit, mirroring gh pr create --fill / --fill-first. Removes the most common create friction and makes one-command PRs viable in scripts.

What changed:

  • git::log_commits(base, head) reads base..head oldest-first with a record/unit-separated --format, so any subject or body byte parses back cleanly. No new API call; purely client-side.
  • cli::pr_fill resolves the title and body from the commit list: a single commit fills the title from its subject and the body from its message; multiple commits use the first subject as the title and a bullet list of subjects as the body. --fill-first takes the first (oldest) commit only. Kept pure so #172's --template path can reuse it.
  • pr create wires in --fill / --fill-first (mutually exclusive). Precedence: an explicit --title / --body / -F always overrides the filled value; with no commits in range it errors instead of opening an empty editor.
  • A cross-repo owner:branch head is stripped to the bare branch before git log, since the commits live under the local name.
  • docs/gh-to-fj.md and CHANGELOG updated.

Tests: 7 unit tests over the pure fill resolver (single/multi/first, empty-range error) and the log-record parser (multi-line bodies, empty range), plus CLI parse tests for the flags and their conflict. Full suite green (540), clippy and fmt clean. Verified the git log format string against real git separators.

Closes #165. `fj pr create` made you retype a title and body the branch's commits already carry. `--fill` derives both from `git log base..head` and `--fill-first` uses only the first commit, mirroring `gh pr create --fill` / `--fill-first`. Removes the most common create friction and makes one-command PRs viable in scripts. What changed: - `git::log_commits(base, head)` reads `base..head` oldest-first with a record/unit-separated `--format`, so any subject or body byte parses back cleanly. No new API call; purely client-side. - `cli::pr_fill` resolves the title and body from the commit list: a single commit fills the title from its subject and the body from its message; multiple commits use the first subject as the title and a bullet list of subjects as the body. `--fill-first` takes the first (oldest) commit only. Kept pure so #172's `--template` path can reuse it. - `pr create` wires in `--fill` / `--fill-first` (mutually exclusive). Precedence: an explicit `--title` / `--body` / `-F` always overrides the filled value; with no commits in range it errors instead of opening an empty editor. - A cross-repo `owner:branch` head is stripped to the bare branch before `git log`, since the commits live under the local name. - docs/gh-to-fj.md and CHANGELOG updated. Tests: 7 unit tests over the pure fill resolver (single/multi/first, empty-range error) and the log-record parser (multi-line bodies, empty range), plus CLI parse tests for the flags and their conflict. Full suite green (540), clippy and fmt clean. Verified the `git log` format string against real git separators.
feat(pr): derive title and body from commits with --fill / --fill-first
All checks were successful
ci / check (pull_request) Successful in 9m58s
ci / coverage (pull_request) Successful in 1m49s
ci / live-e2e (pull_request) Successful in 1m50s
8adf57d9dc
`fj pr create` required retyping a title and body the commits already
carry. `--fill` derives both from `git log base..head`, and `--fill-first`
uses only the first commit, mirroring `gh`.

Closes #165.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rasterstate/fj!174
No description provided.