diff options
author | Philip Kaludercic <philipk@posteo.net> | 2023-02-16 11:11:23 +0100 |
---|---|---|
committer | Philip Kaludercic <philipk@posteo.net> | 2023-02-16 11:11:23 +0100 |
commit | 1c9d81a2b4272200082fc185880856866c0588e1 (patch) | |
tree | 62c7cfd48f10f87fe848e71a05a3e8a7d5a19666 /lisp/emacs-lisp | |
parent | 2550e8bb0b03ee1c2c7a17d56c9f578bbbf1a9da (diff) | |
download | emacs-1c9d81a2b4272200082fc185880856866c0588e1.tar.gz emacs-1c9d81a2b4272200082fc185880856866c0588e1.tar.bz2 emacs-1c9d81a2b4272200082fc185880856866c0588e1.zip |
Attempt to recognise if a VC package has no Elisp files
* lisp/emacs-lisp/package-vc.el (package-vc-non-code-file-names): Add
new variable used to avoid false-positives.
(package-vc--unpack): Recursively search for .el files excluding the
ones listed in 'package-vc-non-code-file-names', offering to abort the
installation if none are found.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/package-vc.el | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index bad59aa6c0f..05df89d264e 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -602,6 +602,13 @@ attribute in PKG-SPEC." (vc-retrieve-tag dir release-rev) (message "No release revision was found, continuing..."))))) +(defvar package-vc-non-code-file-names + '(".dir-locals.el" ".dir-locals-2.el") + "List of file names that do not contain Emacs Lisp code. +This list is used by `package-vc--unpack' to better check if the +user is fetching code from a repository that does not contain any +Emacs Lisp files.") + (defun package-vc--unpack (pkg-desc pkg-spec &optional rev) "Install the package described by PKG-DESC. PKG-SPEC is a package specification, a property list describing @@ -623,6 +630,14 @@ checkout. This overrides the `:branch' attribute in PKG-SPEC." (when (directory-empty-p pkg-dir) (delete-directory pkg-dir) (error "Empty checkout for %s" name)) + (unless (seq-remove + (lambda (file) + (member (file-name-nondirectory file) package-vc-non-code-file-names)) + (directory-files-recursively pkg-dir "\\.el\\'" nil)) + (when (yes-or-no-p (format "No Emacs Lisp files found when fetching \"%s\", \ +abort installation?" name)) + (delete-directory pkg-dir t) + (user-error "Installation aborted"))) ;; When nothing is specified about a `lisp-dir', then should ;; heuristically check if there is a sub-directory with lisp |