renzmann / treesit-auto

Automatic installation, usage, and fallback for tree-sitter major modes in Emacs 29
GNU General Public License v3.0
353 stars 27 forks source link

Can't checkout commit sha for treesit grammar #93

Closed hrehfeld closed 3 months ago

hrehfeld commented 4 months ago

git clone -b only seems to take branches.

⛔ Warning (treesit): Error encountered when installing language grammar: (treesit-error Command: git clone https://github.com/tree-sitter/tree-sitter-python --depth 1 --quiet -b 22d3f87bdafac2782e907330babe4af574f5d0b4 /home/hrehfeld/.emacs.d/temp/treesit-workdirYf5d1g/repo Error output: warning: Could not find remote branch 22d3f87bdafac2782e907330babe4af574f5d0b4 to clone.

Reproduce:

(add-to-list 'treesit-auto-recipe-list
               (make-treesit-auto-recipe
                :lang 'python
                :ts-mode 'python-ts-mode
                :remap '(python-mode)
                :url "https://github.com/tree-sitter/tree-sitter-python"
                :revision "22d3f87bdafac2782e907330babe4af574f5d0b4"
                :source-dir "src"
                :ext "\\.py[iw]?\\'"))

& Restart

With :revision "v0.20.4" it just works.

renzmann commented 3 months ago

This is simply the behavior of treesit-install-language-grammar, and unrelated to treesit-auto.

treesit-install-language-grammar uses treesit-language-source-alist (which is what treesit-auto modifies), and from its documentation:

treesit-language-source-alist is a variable defined in ‘treesit.el’.

Its value is nil

Configuration for downloading and installing tree-sitter language grammars.

The value should be an alist where each element has the form

    (LANG . (URL REVISION SOURCE-DIR CC C++))

Only LANG and URL are mandatory.  LANG is the language symbol.
URL is the Git repository URL for the grammar.

REVISION is the Git tag or branch of the desired version,
defaulting to the latest default branch.

SOURCE-DIR is the relative subdirectory in the repository in which
the grammar’s parser.c file resides, defaulting to "src".

CC and C++ are C and C++ compilers, defaulting to "cc" and
"c++", respectively.

So it's specifically asking for a branch or tag, just as you've observed.