dev(ci): fix commit hash length linter

- Now counts and reports all commit references that aren't the correct
  length, not just the first.
- Now reports all incorrect references, not just the first on each line.
This commit is contained in:
Henrik Lissner 2021-09-29 18:26:10 +02:00
parent 2f100fef04
commit 1cbd1e14e1

View file

@ -146,12 +146,14 @@
(fn! (&key body) (fn! (&key body)
(with-temp-buffer (with-temp-buffer
(insert body) (insert body)
(catch 'result (let ((bump-re "\\<\\(?:https?://[^@]+\\|[^/]+\\)/[^/]+@\\([a-z0-9]+\\)")
(let ((bump-re "^\\(?:https?://.+\\|[^/]+\\)/[^/]+@\\([a-z0-9]+\\)")) refs)
(while (re-search-backward bump-re nil t) (while (re-search-backward bump-re nil t)
(when (/= (length (match-string 1)) 12) (when (/= (length (match-string 1)) 12)
(throw 'result (cons 'error (format "Commit hash in %S must be 12 characters long" (push (match-string 0) refs)))
(match-string 0)))))))))) (when refs
(cons 'error (format "%d commit hash(s) not 12 characters long: %s"
(length refs) (string-join (nreverse refs) ", ")))))))
;; TODO Add bump validations for revert: type. ;; TODO Add bump validations for revert: type.