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)
(with-temp-buffer
(insert body)
(catch 'result
(let ((bump-re "^\\(?:https?://.+\\|[^/]+\\)/[^/]+@\\([a-z0-9]+\\)"))
(while (re-search-backward bump-re nil t)
(when (/= (length (match-string 1)) 12)
(throw 'result (cons 'error (format "Commit hash in %S must be 12 characters long"
(match-string 0))))))))))
(let ((bump-re "\\<\\(?:https?://[^@]+\\|[^/]+\\)/[^/]+@\\([a-z0-9]+\\)")
refs)
(while (re-search-backward bump-re nil t)
(when (/= (length (match-string 1)) 12)
(push (match-string 0) refs)))
(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.