[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#68579: [PATCH] Support a local repo as URL in treesit-language-sourc
From: |
Eli Zaretskii |
Subject: |
bug#68579: [PATCH] Support a local repo as URL in treesit-language-source-alist |
Date: |
Fri, 19 Jan 2024 10:33:45 +0200 |
> From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
> Date: Fri, 19 Jan 2024 11:08:00 +0300
>
> So what this patch does is it adds detection of a full path to the
> treesit-language-source-alist processing to make sure we avoid cloning
> the repo in that case and just proceed building it.
Thanks. Some comments below, and I added Yuan to the discussion.
> From c9de59a39566a5df46aa39ef93348487bb2948aa Mon Sep 17 00:00:00 2001
> From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
> Date: Fri, 19 Jan 2024 10:33:47 +0300
> Subject: [PATCH] Support a local repo as URL in treesit-language-source-alist
>
> Sometimes people may need to bisect to find specific revision in a
> grammar repo. In this case they'd want to point the URL to the local
> repo to avoid cloning it on every rebuild. So add support for full
> path in treesit-language-source-alist.
>
> * lisp/treesit.el (treesit--install-language-grammar-1): test if URL
> starts with / meaning that the URL is a local path. Then if it is,
> avoid cloning the repo and removing the path on success.
> (treesit--git-clone-repo): factor out the code for cloning to a separate
> function.
> (treesit--git-checkout-branch): a helper to checkout the revision for
> cases where we didn't clone the repo but want it to point the
> revision.
These descriptions should be full sentences: start with a capital
letter and end in a period. Also, please leave two spaces between
sentences.
> Only LANG and URL are mandatory. LANG is the language symbol.
> -URL is the Git repository URL for the grammar.
> +URL is the Git repository URL or full path for the grammar.
GNU Coding Standards frown on using "path" for anything but PATH-style
directory lists. In this case, you mean "directory name".
> +(defun treesit--git-checkout-branch (repo-path revision)
> + "Checkout `revision' in a repo located in `repo-path'"
References to arguments in doc strings should be capitalized and not
quoted: REVISION and REPO-PATH (which should be renamed to REPO-DIR).
> +(defun treesit--git-clone-repo (url revision workdir)
> + "Clone repo pointed by `url' at commit `revision' to `workdir'"
Likewise.
Also, please document in the doc string what happens if REVISION is
nil.
> + ;; don't clone if url is a local path
Comments should be complete sentences: begin with a capital letter and
end with a period.
> + (url-is-path (string-prefix-p "/" url))
"Path" used wrongly again. Also, the string-prefix-p test is too
naïve and unportable. I think file-name-absolute-p is a better test
(assuming we expect an absolute file name there), perhaps also
augmented by file-accessible-directory-p.
> - (workdir (expand-file-name "repo"))
> + (workdir (if url-is-path url (expand-file-name "repo")))
Not sure about this hunk: why do we not need to expand-file-name if
URL is not a local directory but a real URL?
> + (if url-is-path
> + (when revision
> + (treesit--git-checkout-branch url revision))
Isn't the above equivalent to
(and url-is-path revision
(treesit--git-checkout-branch url revision))
?
> - (when (file-exists-p workdir)
> + (when (and (not url-is-path) (file-exists-p workdir))
> (delete-directory workdir t)))))
Why? Does workdir have different semantics in these two use cases?
Isn't it the directory where we cloned the repository?
Finally, this needs a NEWS entry.
- bug#68579: [PATCH] Support a local repo as URL in treesit-language-source-alist, Konstantin Kharlamov, 2024/01/19
- bug#68579: [PATCH] Support a local repo as URL in treesit-language-source-alist,
Eli Zaretskii <=
- bug#68579: [PATCH] Support a local repo as URL in treesit-language-source-alist, Konstantin Kharlamov, 2024/01/19
- bug#68579: [PATCH] Support a local repo as URL in treesit-language-source-alist, Eli Zaretskii, 2024/01/19
- bug#68579: [PATCH] Support a local repo as URL in treesit-language-source-alist, Konstantin Kharlamov, 2024/01/19
- bug#68579: [PATCH] Support a local repo as URL in treesit-language-source-alist, Eli Zaretskii, 2024/01/19
- bug#68579: [PATCH] Support a local repo as URL in treesit-language-source-alist, Konstantin Kharlamov, 2024/01/19
- bug#68579: [PATCH] Support a local repo as URL in treesit-language-source-alist, Eli Zaretskii, 2024/01/19
- bug#68579: [PATCH v2] Support a local repo as URL in treesit-language-source-alist, Konstantin Kharlamov, 2024/01/20
- bug#68579: [PATCH v2] Support a local repo as URL in treesit-language-source-alist, Konstantin Kharlamov, 2024/01/20
bug#68579: [PATCH v2] Support a local repo as URL in treesit-language-source-alist, Konstantin Kharlamov, 2024/01/20