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