From: Eli Zaretskii <eliz@gnu.org>
To: Konstantin Kharlamov <Hi-Angel@yandex.ru>, Yuan Fu <casouri@gmail.com>
Cc: 68579@debbugs.gnu.org
Subject: bug#68579: [PATCH] Support a local repo as URL in treesit-language-source-alist
Date: Fri, 19 Jan 2024 10:33:45 +0200 [thread overview]
Message-ID: <83frytwwly.fsf@gnu.org> (raw)
In-Reply-To: <0ffc2f474cf84ed3c63aa82091c967807e5ca0e6.camel@yandex.ru> (message from Konstantin Kharlamov on Fri, 19 Jan 2024 11:08:00 +0300)
> 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.
next prev parent reply other threads:[~2024-01-19 8:33 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-19 8:08 bug#68579: [PATCH] Support a local repo as URL in treesit-language-source-alist Konstantin Kharlamov
2024-01-19 8:33 ` Eli Zaretskii [this message]
2024-01-19 8:57 ` Konstantin Kharlamov
2024-01-19 11:46 ` Eli Zaretskii
2024-01-19 14:33 ` Konstantin Kharlamov
2024-01-19 15:06 ` Eli Zaretskii
2024-01-19 16:06 ` Konstantin Kharlamov
2024-01-19 16:26 ` Eli Zaretskii
2024-01-20 12:00 ` bug#68579: [PATCH v2] " Konstantin Kharlamov
2024-01-20 12:04 ` Konstantin Kharlamov
2024-01-20 11:56 ` Konstantin Kharlamov
2024-01-27 9:37 ` Eli Zaretskii
2024-01-27 18:53 ` Konstantin Kharlamov
2024-01-27 19:21 ` Eli Zaretskii
2024-02-01 10:06 ` Eli Zaretskii
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=83frytwwly.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=68579@debbugs.gnu.org \
--cc=Hi-Angel@yandex.ru \
--cc=casouri@gmail.com \
/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.