Skip to content

mhuxtable/github-commit-helper-extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub PR Commit Message Toolbox

A Firefox extension that enforces good commit message discipline in GitHub's PR merge dialogs through sane defaults and additional tools.

When you merge a PR on GitHub, the commit message is typically pre-filled with the PR description or a listing of individual commit messages. It might contain markdown headings, bold text, image tags, URLs, and long lines. It is difficult to edit the description in situ to tidy this, because there is no indication of line width. For years, I've copy-pasted descriptions out to my editor just to reflow to 72 character long lines, which is lots of unnecessary effort.

⏩ No more! This extension strips the formatting and reflows the text to a configurable column width. It also provides a toolbar to allow repeated reflowing of the text post-editing; no more copy-pasting into your editor to get well-formatted commit messages! 🎉

Before and after: markdown stripped and text reflowed to 72 columns

What it does

  • Monospace font – Switches the commit title and body fields to a monospace font so you can see exactly how the message will look in the terminal.
  • Column ruler and overflow highlighting – Draws a vertical guide at the configured column width (default 72) and highlights text that exceeds it in red, for both the title and body fields. Title field with character counter and column guide
  • Title character counter – Shows a live N/72 counter in the title field that turns red when you go over the limit.
  • Auto-format on load – When the merge dialog opens, the extension strips markdown formatting (headings, bold, italic, links, images, fenced code blocks, HTML tags) and reflows the text to the configured column width. Fenced code blocks are converted to 4-space indented blocks so they survive the reflow untouched.
  • Manual reflow – A toolbar below the body field lets you reflow text on demand. The reflow algorithm tries to achieve a similar output to gq in Vim/Neovim: it preserves paragraph breaks, list item structure with hanging indents, indented code blocks, and git trailers (Co-authored-by, Signed-off-by, etc.).
  • Undo – Auto-formatting can be reverted with a single click. Manual reflows use execCommand under the hood, so Ctrl/Cmd+Z works natively.

Settings

Click the extension icon to configure:

Settings popup

Setting Default Description
Title width 72 Character guide limit for the subject line
Body width 72 Wrap column guide limit for the extended description
Auto-format on load On Strip markdown and reflow when the merge dialog opens

Install

Install from addons.mozilla.org, or run from source with yarn start.

Development

yarn test       # run tests
yarn build      # package .zip for AMO
yarn lint       # validate manifest and sources

Licence

MPL-2.0

About

Firefox extension that enforces good commit message discipline in GitHub PR merge dialogs: monospace font, column rulers, and automatic markdown-to-plaintext reflow.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages