Repository navigation
Commit 4ddaec6
authored
Allow URL-only lines to exceed TextWidth body limit (sds#900)
## 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 sds#822
## Checklist
- [x] 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 comment1 parent c06c0f5 commit 4ddaec6
2 files changed
Lines changed: 44 additions & 4 deletions
File tree
- lib/overcommit/hook/commit_msg
- spec/overcommit/hook/commit_msg
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
7 | 12 | | |
8 | 13 | | |
9 | 14 | | |
| |||
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
52 | 61 | | |
53 | 62 | | |
54 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
76 | 107 | | |
77 | 108 | | |
78 | 109 | | |
| |||
0 commit comments