fix(cli): infinite loop linting long lines in commits

Fix: #8425
This commit is contained in:
Henrik Lissner
2025-07-13 21:26:05 +02:00
parent dd89efdb42
commit ed9190ef00

View File

@ -118,23 +118,24 @@ Each element of this list can be one of:
(unless (equal scopes (sort (copy-sequence scopes) #'string-lessp))
(fail! "Scopes are not in lexicographical order")))
(lambda! (&key type body)
(lambda! (&key _type body)
"Enforce 72 character line width for BODY"
(catch 'result
(with-temp-buffer
(save-excursion (insert body))
(while (re-search-forward "^[^\n]\\{73,\\}" nil t)
(save-excursion
(let ((bol (match-beginning 0)))
(or
;; Long bump lines are acceptable
(let ((bump-re "\\(https?://.+\\|[^/]+\\)/[^/]+@[a-z0-9]\\{12\\}"))
(re-search-backward (format "^%s -> %s$" bump-re bump-re) nil t))
(re-search-backward (format "^%s -> %s$" bump-re bump-re) bol t))
;; Long URLs are acceptable
(re-search-backward "https?://[^ ]+\\{73,\\}" nil t)
(re-search-backward "https?://[^ \n]+" bol t)
;; Lines that start with # or whitespace are comment or
;; code blocks.
(re-search-backward "^\\(?:#\\| +\\)" nil t)
(throw 'result (fail! "Line(s) in commit body exceed 72 characters"))))))))
(re-search-backward "^\\(?:#\\| +\\)" bol t)
(throw 'result (fail! "Line(s) in commit body exceed 72 characters")))))))))
(lambda! (&key bang body type)
"Ensure ! is accompanied by a 'BREAKING CHANGE:' in BODY"