From: Peter Oliver <p.d.oliver@mavit.org.uk>
To: Yuan Fu <casouri@gmail.com>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: Validating tree-sitter major modes and grammar
Date: Fri, 3 Jan 2025 12:26:30 +0000 (GMT) [thread overview]
Message-ID: <e005cffe-c3e7-3f07-5351-bb87124f2545@mavit.org.uk> (raw)
In-Reply-To: <c746679f-55bd-649c-00c5-18a7c96b2dbb@mavit.org.uk>
[-- Attachment #1: Type: text/plain, Size: 810 bytes --]
On Thu, 2 Jan 2025, Peter Oliver wrote:
> On Mon, 30 Dec 2024, Yuan Fu wrote:
>
>> Anyway, as a first step, I added a command that generates a html file that
>> looks like the below. I’ll try setting up a cron job on my machine, then
>> we can figure out how do we run it on EMBA and how to host the generated
>> webpage.
>>
>> Peter, do you have any suggestions after seeing this example webpage?
>
> Looks good.
>
> Rather than the latest commit, I’d be more interested in the latest release
> (i.e., commit tagged with a tag starting “v”). I’d only consider packaging a
> Git snapshot as a last resort to solve an important bug, so tagged commits
> are more relevant to me.
So, then, something along the lines of the attached (although, actually, maybe we want both?).
--
Peter Oliver
[-- Attachment #2: Type: text/plain, Size: 1278 bytes --]
From c1405db6560273ce4eaf0d5c1b13932b876b72a0 Mon Sep 17 00:00:00 2001
From: Peter Oliver <git@mavit.org.uk>
Date: Fri, 3 Jan 2025 12:02:50 +0000
Subject: [PATCH 1/2] New function treesit--language-git-version-tags
* lisp/treesit.el (treesit--language-git-version-tags): New function to
list version tags for a Tree-sitter parser Git repository.
---
lisp/treesit.el | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/lisp/treesit.el b/lisp/treesit.el
index f3c553fdb8f..a89fa2ae13e 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -4262,6 +4262,18 @@ treesit--language-git-revision
(string-trim (buffer-string)))
(t nil))))
+(defun treesit--language-git-version-tags (repo-dir)
+ "Return a list of Git version tags in REPO-DIR, sorted latest first.
+
+Return the output of \"git tag --list --sort=-version:refname 'v*'\". If
+anything goes wrong, return nil."
+ (with-temp-buffer
+ (cond
+ ((eq 0 (call-process "git" nil t nil "-C" repo-dir "tag"
+ "--list" "--sort=-version:refname" "v*"))
+ (split-string (buffer-string)))
+ (t nil))))
+
(defun treesit--language-git-timestamp (repo-dir)
"Return the commit date in REPO-DIR in UNIX epoch.
--
2.47.1
[-- Attachment #3: Type: text/plain, Size: 6207 bytes --]
From 0a0348f6410772919007e922f1cc338159d741e4 Mon Sep 17 00:00:00 2001
From: Peter Oliver <git@mavit.org.uk>
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;
}
</style>
</head>
<body>
<h1>Emacs tree-sitter grammar compatibility</h1>
- <p>This is an auto-generated report of the last compatible version for each grammar in each Emacs version. A <span class="head">green background</span> on the version indicates that the Emacs version is compatible with the latest commit in the upstream grammar repo.</p>
+ <p>This is an auto-generated report of the last compatible version for each grammar in each Emacs version. A <span class="head">green background</span> on the version indicates that the Emacs version is compatible with the latest tag in the upstream grammar repo.</p>
<p>This report is generated on ___REPLACE_TIME___.</p>
<table>
___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 "<td></td>")
(insert (format "<td class=\"%s\">%s</td>"
--
2.47.1
next prev parent reply other threads:[~2025-01-03 12:26 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-20 9:09 Validating tree-sitter major modes and grammar Yuan Fu
2024-12-20 12:24 ` Eli Zaretskii
2024-12-20 16:22 ` Yuan Fu
2024-12-23 0:44 ` Björn Bidar
[not found] ` <868qs6vd76.fsf@aarsen.me>
2024-12-24 1:16 ` Yuan Fu
2024-12-24 3:12 ` Yuan Fu
2024-12-24 12:19 ` Eli Zaretskii
2024-12-24 21:30 ` Yuan Fu
2024-12-24 23:09 ` Dmitry Gutov
2024-12-25 8:39 ` Yuan Fu
2024-12-26 2:23 ` Dmitry Gutov
2025-01-02 3:30 ` Yuan Fu
[not found] ` <6768b29d.050a0220.1b40f2.5574SMTPIN_ADDED_BROKEN@mx.google.com>
2024-12-24 3:20 ` Yuan Fu
2024-12-24 12:36 ` Peter Oliver
2024-12-24 14:20 ` Michael Albinus
2024-12-24 22:20 ` Yuan Fu
2024-12-25 8:20 ` Michael Albinus
2024-12-25 9:33 ` Yuan Fu
2024-12-25 13:51 ` Michael Albinus
2024-12-26 12:54 ` Peter Oliver
2024-12-26 17:50 ` Michael Albinus
2024-12-28 12:02 ` Michael Albinus
2024-12-30 8:08 ` Yuan Fu
2025-01-02 16:48 ` Peter Oliver
2025-01-03 12:26 ` Peter Oliver [this message]
2025-01-04 8:31 ` Yuan Fu
2024-12-24 22:14 ` Yuan Fu
2024-12-24 21:36 ` Björn Bidar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e005cffe-c3e7-3f07-5351-bb87124f2545@mavit.org.uk \
--to=p.d.oliver@mavit.org.uk \
--cc=casouri@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.