Skip to content

Allow URL-only lines to exceed TextWidth body limit - #900

Open
anyingiit wants to merge 1 commit into
sds:mainfrom
anyingiit:text-width-allow-long-urls
Open

anyingiit wants to merge 1 commit into
sds:mainfrom
anyingiit:text-width-allow-long-urls

Conversation

@anyingiit

Copy link
Copy Markdown

Description

CommitMsg::TextWidth warns on every body line longer than max_body_width, including lines that contain nothing but a URL. A URL can't be wrapped without breaking it (in the terminal and on GitHub), so these warnings can't be fixed without making the message worse.

This PR exempts body lines that consist solely of a URL (scheme://..., surrounding whitespace ignored), optionally written as a Markdown-style link reference such as [1]: https://.... Lines that mix a URL with other text are still checked as before, and the subject line checks are unchanged. No new configuration option is added; the exemption is always on, since an over-long URL-only line is never actionable.

Motivation / disclosure: I had some spare AI-assistant quota (Claude Code) and am using it to try to
help projects with open good-first-issues. The change was prepared with Claude Code and verified as listed
below. If it doesn't fit, isn't up to your bar, or you'd simply rather not take it — please feel free to
close it, no hard feelings at all 🙂

Related issue

Closes #822

Checklist

  • Tests pass locally (bundle exec rspec spec/overcommit/hook/commit_msg/text_width_spec.rb: 19 examples, 0 failures; the 2 new URL-only specs fail without the fix. Full bundle exec rspec on Ruby 3.4: 1647 examples, 1 failure (utils_spec.rb:35, repo_root with no .git directory), which fails identically on main in my environment. bundle exec overcommit --run: all pre-commit hooks passed)
  • CHANGELOG.md is updated (if applicable) — n/a, entries appear to be added when a version is cut; happy to add one if you prefer
  • Documentation is updated (if applicable) — n/a, the behavior is described in the hook's source comment

A URL cannot be wrapped without breaking it, so a commit message body
line that consists only of a URL (optionally written as a Markdown-style
link reference such as `[1]: https://...`) no longer triggers the
`max_body_width` warning. Lines that mix a URL with other text are still
checked as before.

Closes sds#822

This branch has not been deployed

No deployments
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.

[Feature Request] Overcommit TextWidth should not fail if a commit line containing only a url is longer than preferred length

1 participant