feat(submit): unwrap hard line breaks in generated PR descriptions#34
feat(submit): unwrap hard line breaks in generated PR descriptions#34
Conversation
Stack
Managed by gh-stack |
There was a problem hiding this comment.
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
generatePRBodyto 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.
c818766 to
e25fdac
Compare
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.
e25fdac to
562c0e6
Compare
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`.
There was a problem hiding this comment.
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
Commit message bodies are typically hard-wrapped at ~72 columns, but
GitHub renders single newlines as
<br>in PR descriptions, resultingin ugly narrow paragraphs.
generatePRBodynow unwraps paragraphlines 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.