commit:     a9abb500be95b3465d288d11fb974378e6126f82
Author:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 21 18:01:06 2025 +0000
Commit:     Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Jul 21 18:22:53 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a9abb500

dev-util/pkgcheck: add support for dev-python/tree-sitter-0.25.0

Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>

 .../pkgcheck/files/pkgcheck-0.10.36-ts0.25.patch   | 66 ++++++++++++++++++++++
 ...k-0.10.36.ebuild => pkgcheck-0.10.36-r1.ebuild} |  5 ++
 dev-util/pkgcheck/pkgcheck-9999.ebuild             |  1 +
 3 files changed, 72 insertions(+)

diff --git a/dev-util/pkgcheck/files/pkgcheck-0.10.36-ts0.25.patch 
b/dev-util/pkgcheck/files/pkgcheck-0.10.36-ts0.25.patch
new file mode 100644
index 000000000000..0e728e848ce0
--- /dev/null
+++ b/dev-util/pkgcheck/files/pkgcheck-0.10.36-ts0.25.patch
@@ -0,0 +1,66 @@
+Subject: [PATCH] bash: update support to tree-sitter~=0.25
+
+Also add backward compatible code for tree-sitter < 0.25.
+
+Signed-off-by: Arthur Zamarin <[email protected]>
+--- a/pyproject.toml
++++ b/pyproject.toml
+@@ -6,7 +6,7 @@ requires = [
+       "lazy-object-proxy",
+       "lxml",
+       "pathspec",
+-      "tree-sitter~=0.24.0",
++      "tree-sitter~=0.25.0",
+       "tree-sitter-bash~=0.23.1",
+       "snakeoil~=0.10.11",
+       "pkgcore~=0.12.30",
+@@ -45,7 +45,7 @@ dependencies = [
+       "lazy-object-proxy",
+       "lxml",
+       "pathspec",
+-      "tree-sitter~=0.24.0",
++      "tree-sitter~=0.25.0",
+       "tree-sitter-bash~=0.23.1",
+       "snakeoil~=0.10.11",
+       "pkgcore~=0.12.30",
+--- a/src/pkgcheck/bash/__init__.py
++++ b/src/pkgcheck/bash/__init__.py
+@@ -6,7 +6,17 @@ import tree_sitter_bash
+ from tree_sitter import Language, Parser, Query
+
+ lang = Language(tree_sitter_bash.language())
+-query = lang.query
++
++try:
++    from tree_sitter import QueryCursor
++
++    def query(query_str: str) -> "QueryCursor":
++        return QueryCursor(Query(lang, query_str))
++except ImportError:  # tree-sitter < 0.25
++    QueryCursor = Query
++    query = lang.query
++
++
+ parser = Parser(language=lang)
+
+ # various parse tree queries
+@@ -29,14 +39,14 @@ class ParseTree:
+         """Return the ebuild string associated with a given parse tree 
node."""
+         return self.data[node.start_byte : node.end_byte].decode("utf8")
+
+-    def global_query(self, query: Query):
++    def global_query(self, query: QueryCursor):
+         """Run a given parse tree query returning only those nodes in global 
scope."""
+         for x in self.tree.root_node.children:
+             # skip nodes in function scope
+             if x.type != "function_definition":
+                 yield from chain.from_iterable(query.captures(x).values())
+
+-    def func_query(self, query: Query):
++    def func_query(self, query: QueryCursor):
+         """Run a given parse tree query returning only those nodes in 
function scope."""
+         for x in self.tree.root_node.children:
+             # only return nodes in function scope
+--
+2.50.1
+

diff --git a/dev-util/pkgcheck/pkgcheck-0.10.36.ebuild 
b/dev-util/pkgcheck/pkgcheck-0.10.36-r1.ebuild
similarity index 96%
rename from dev-util/pkgcheck/pkgcheck-0.10.36.ebuild
rename to dev-util/pkgcheck/pkgcheck-0.10.36-r1.ebuild
index dedc375e9b15..ffa0bc885126 100644
--- a/dev-util/pkgcheck/pkgcheck-0.10.36.ebuild
+++ b/dev-util/pkgcheck/pkgcheck-0.10.36-r1.ebuild
@@ -55,8 +55,13 @@ BDEPEND="${RDEPEND}
        )
 "
 
+PATCHES=(
+       "${FILESDIR}"/${P}-ts0.25.patch
+)
+
 SITEFILE="50${PN}-gentoo.el"
 
+EPYTEST_PLUGINS=( pkgcore )
 distutils_enable_tests pytest
 
 export USE_SYSTEM_TREE_SITTER_BASH=1

diff --git a/dev-util/pkgcheck/pkgcheck-9999.ebuild 
b/dev-util/pkgcheck/pkgcheck-9999.ebuild
index 8a8dae53dfcc..fe24988ed2ca 100644
--- a/dev-util/pkgcheck/pkgcheck-9999.ebuild
+++ b/dev-util/pkgcheck/pkgcheck-9999.ebuild
@@ -56,6 +56,7 @@ BDEPEND="${RDEPEND}
 
 SITEFILE="50${PN}-gentoo.el"
 
+EPYTEST_PLUGINS=( pkgcore )
 distutils_enable_tests pytest
 
 export USE_SYSTEM_TREE_SITTER_BASH=1

Reply via email to