emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 1c9d81a2b42: Attempt to recognise if a VC package has no Elisp


From: Philip Kaludercic
Subject: emacs-29 1c9d81a2b42: Attempt to recognise if a VC package has no Elisp files
Date: Thu, 16 Feb 2023 05:11:46 -0500 (EST)

branch: emacs-29
commit 1c9d81a2b4272200082fc185880856866c0588e1
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>

    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.
---
 lisp/emacs-lisp/package-vc.el | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]