Skip to content

feat(submit): unwrap hard line breaks in generated PR descriptions#34

Merged
boneskull merged 3 commits intomainfrom
reformat-pr-desc
Feb 12, 2026
Merged

feat(submit): unwrap hard line breaks in generated PR descriptions#34
boneskull merged 3 commits intomainfrom
reformat-pr-desc

Conversation

@boneskull
Copy link
Owner

Commit message bodies are typically hard-wrapped at ~72 columns, but
GitHub renders single newlines as <br> in PR descriptions, resulting
in ugly narrow paragraphs. generatePRBody now unwraps paragraph
lines while preserving markdown structure (code blocks, lists, headers,
blockquotes, tables, horizontal rules). If HTML tags are detected, the
body is left as-is to avoid mangling intentional formatting.

@boneskull
Copy link
Owner Author

Stack


Managed by gh-stack

Copilot AI review requested due to automatic review settings February 12, 2026 00:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the submit command’s generated PR descriptions by unwrapping hard-wrapped commit message paragraphs (while preserving common Markdown structures) to avoid narrow paragraphs rendered with <br> on GitHub. It also introduces a pre-commit lint hook via Lefthook and adds tests for the new unwrapping behavior.

Changes:

  • Update generatePRBody to unwrap paragraph line breaks in commit bodies while preserving Markdown block structure.
  • Add unit tests covering unwrapping behavior and Markdown preservation/bail-out cases.
  • Add Lefthook pre-commit linting and Makefile targets to install tooling and hooks.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.

File Description
cmd/submit.go Adds paragraph unwrapping logic and applies it to generated PR bodies.
cmd/submit_internal_test.go Adds tests for unwrapping and Markdown structure detection helpers.
lefthook.yml Introduces a pre-commit golangci-lint hook.
Makefile Adds tools/hooks targets and installs Lefthook.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Commit message bodies are typically hard-wrapped at ~72 columns, but
GitHub renders single newlines as `<br>` in PR descriptions, resulting
in ugly narrow paragraphs. `generatePRBody` now unwraps paragraph
lines while preserving markdown structure (code blocks, lists, headers,
blockquotes, tables, horizontal rules). If HTML tags are detected, the
body is left as-is to avoid mangling intentional formatting.
Copilot AI review requested due to automatic review settings February 12, 2026 01:01
The fenced code block state machine treated `````` and `~~~` as
interchangeable openers/closers. Now each code block tracks which
marker opened it and only closes on the same marker, preventing a
`~~~` inside a `````` block (or vice versa) from prematurely
ending code block mode.

Also adds explanatory comment to `submit_internal_test.go` for why it
uses `package cmd` instead of `package cmd_test`.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Expand `htmlTagRe` to match custom elements with hyphens (e.g.
  `<my-component>`) and namespaced tags (e.g. `<xml:tag>`)
- Move orphaned doc comment block to directly precede
  `unwrapParagraphs` so it attaches to the function in godoc
@boneskull boneskull added the enhancement New feature or request label Feb 12, 2026
@boneskull boneskull merged commit 15edb71 into main Feb 12, 2026
7 checks passed
@boneskull boneskull deleted the reformat-pr-desc branch February 12, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants