From 0a0348f6410772919007e922f1cc338159d741e4 Mon Sep 17 00:00:00 2001 From: Peter Oliver Date: Fri, 3 Jan 2025 12:09:32 +0000 Subject: [PATCH 2/2] Tweak Tree-sitter compatibility report to show only tagged versions * admin/tree-sitter/compat-template.html: Rename class head to latest. * admin/tree-sitter/treesit-admin.el (treesit-admin--find-latest-compatible-revision): Inspect only tagged commits, as given by treesit--language-git-revision. --- admin/tree-sitter/compat-template.html | 4 +-- admin/tree-sitter/treesit-admin.el | 39 +++++++++++++------------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/admin/tree-sitter/compat-template.html b/admin/tree-sitter/compat-template.html index 23b5b55d7b3..680301d14a4 100644 --- a/admin/tree-sitter/compat-template.html +++ b/admin/tree-sitter/compat-template.html @@ -23,14 +23,14 @@ width: 10rem; word-break: break-all; } - .head { + .latest { background: lightgreen; }

Emacs tree-sitter grammar compatibility

-

This is an auto-generated report of the last compatible version for each grammar in each Emacs version. A green background on the version indicates that the Emacs version is compatible with the latest commit in the upstream grammar repo.

+

This is an auto-generated report of the last compatible version for each grammar in each Emacs version. A green background on the version indicates that the Emacs version is compatible with the latest tag in the upstream grammar repo.

This report is generated on ___REPLACE_TIME___.

___REPLACE_TABLE___ diff --git a/admin/tree-sitter/treesit-admin.el b/admin/tree-sitter/treesit-admin.el index 3711eb0a301..a69131c1c9d 100644 --- a/admin/tree-sitter/treesit-admin.el +++ b/admin/tree-sitter/treesit-admin.el @@ -296,9 +296,9 @@ treesit-admin--find-latest-compatible-revision Return a plist of the form - (:version VERSION :head-version HEAD-VERSION :timstamp TIMESTAMP). + (:version VERSION :latest-version LATEST-VERSION :timstamp TIMESTAMP). -HEAD-VERSION is the version of the HEAD, VERSION is the latest +LATEST-VERSION is the latest version, VERSION is the latest compatible version. TIMESTAMP is the commit date of VERSION in UNIX epoch format." (let ((treesit-extra-load-path (list grammar-dir)) @@ -309,7 +309,8 @@ treesit-admin--find-latest-compatible-revision (emacs-executable (or emacs-executable (expand-file-name invocation-name invocation-directory))) - head-version version exit-code timestamp) + (latest-version nil) + latest-version version exit-code timestamp) (when (not recipe) (signal 'treesit-error `("Cannot find recipe" ,language))) (pcase-let ((`(,url ,revision ,source-dir ,cc ,c++ ,commit) @@ -318,17 +319,14 @@ treesit-admin--find-latest-compatible-revision (treesit--git-clone-repo url revision workdir) (when commit (treesit--git-checkout-branch workdir commit)) - (setq head-version (treesit--language-git-revision workdir)) - (treesit--build-grammar - workdir grammar-dir language source-dir cc c++) - (while (not (eq exit-code 0)) - (unless (null exit-code) - (treesit--git-checkout-branch workdir "HEAD~") - (treesit--build-grammar - workdir grammar-dir language source-dir cc c++)) - (setq version (treesit--language-git-revision workdir)) + (dolist (tag (treesit--language-git-version-tags workdir)) + (unless latest-version + (setq latest-version tag)) + (treesit--git-checkout-branch workdir tag) + (treesit--build-grammar + workdir grammar-dir language source-dir cc c++) (setq timestamp (treesit--language-git-timestamp workdir)) - (message "Validateing version %s" version) + (message "Validating version %s" tag) (setq exit-code (call-process emacs-executable nil t nil @@ -340,8 +338,11 @@ treesit-admin--find-latest-compatible-revision (if (treesit-admin--validate-mode-lang ',mode ',language) (kill-emacs 0) - (kill-emacs -1))))))))) - (list :version version :head-version head-version :timestamp timestamp))) + (kill-emacs -1)))))) + (when (eq exit-code 0) + (setq version tag) + (cl-return))))) + (list :version version :latest-version latest-version :timestamp timestamp))) (defun treesit-admin--last-compatible-grammar-for-modes (modes source-alist grammar-dir &optional emacs-executable) @@ -353,9 +354,9 @@ treesit-admin--last-compatible-grammar-for-modes Return an alist of an alist of a plist: - ((MODE . ((LANG . (:version VERSION :head-VERSION HEAD-VERSION)) ...)) ...) + ((MODE . ((LANG . (:version VERSION :latest-version LATEST-VERSION)) ...)) ...) -VERSION and HEAD-VERSION in the plist are the same as in +VERSION and LATEST-VERSION in the plist are the same as in `treesit-admin--find-latest-compatible-revision'." (mapcar (lambda (mode) @@ -427,9 +428,9 @@ treesit-admin--generate-compatibility-report (let* ((key (cons lang emacs-version)) (plist (gethash key database)) (version (plist-get plist :version)) - (head-version (plist-get plist :head-version)) + (latest-version (plist-get plist :latest-version)) (classname - (if (equal version head-version) "head" ""))) + (if (equal version latest-version) "latest" ""))) (if (not plist) (insert "") (insert (format "" -- 2.47.1
%s