From 1cbd1e14e185ff0052a488fd97ae417b8c6e3d27 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 29 Sep 2021 18:26:10 +0200 Subject: [PATCH] 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. --- core/cli/ci.el | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/cli/ci.el b/core/cli/ci.el index 6e99fd7f6..cf0198747 100644 --- a/core/cli/ci.el +++ b/core/cli/ci.el @@ -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.