diff options
| author | Stefan Kangas | 2019-10-20 23:49:18 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2019-10-21 00:00:36 +0200 |
| commit | 0e6f4628d8fff53505e4399e71da9f531a64fff7 (patch) | |
| tree | 22b587b6b12cba555590d22f586b94d5eccd30c1 | |
| parent | 78cb3791fa11c95756ee3917c63cfea774f128a2 (diff) | |
| download | emacs-0e6f4628d8fff53505e4399e71da9f531a64fff7.tar.gz emacs-0e6f4628d8fff53505e4399e71da9f531a64fff7.zip | |
Don't try to add nil packages on refresh
* lisp/emacs-lisp/package.el (package-read-archive-contents): Don't
try to add nil entries. Warn instead. (Bug#28502)
* test/lisp/emacs-lisp/package-tests.el
(package-test-update-archives/ignore-nil-entry): New test.
* test/lisp/emacs-lisp/package-resources/with-nil-entry/archive-contents:
New file.
| -rw-r--r-- | lisp/emacs-lisp/package.el | 5 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/package-resources/with-nil-entry/archive-contents | 8 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/package-tests.el | 10 |
3 files changed, 22 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 20462064afd..645e831bcc9 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el | |||
| @@ -1520,7 +1520,10 @@ If the archive version is too new, signal an error." | |||
| 1520 | (contents (package--read-archive-file contents-file))) | 1520 | (contents (package--read-archive-file contents-file))) |
| 1521 | (when contents | 1521 | (when contents |
| 1522 | (dolist (package contents) | 1522 | (dolist (package contents) |
| 1523 | (package--add-to-archive-contents package archive))))) | 1523 | (if package |
| 1524 | (package--add-to-archive-contents package archive) | ||
| 1525 | (lwarn '(package refresh) :warning | ||
| 1526 | "Ignoring `nil' package on `%s' package archive" archive)))))) | ||
| 1524 | 1527 | ||
| 1525 | (defvar package--old-archive-priorities nil | 1528 | (defvar package--old-archive-priorities nil |
| 1526 | "Store currently used `package-archive-priorities'. | 1529 | "Store currently used `package-archive-priorities'. |
diff --git a/test/lisp/emacs-lisp/package-resources/with-nil-entry/archive-contents b/test/lisp/emacs-lisp/package-resources/with-nil-entry/archive-contents new file mode 100644 index 00000000000..03e6aa7f7c6 --- /dev/null +++ b/test/lisp/emacs-lisp/package-resources/with-nil-entry/archive-contents | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | (1 | ||
| 2 | (foo . | ||
| 3 | [(1 0) | ||
| 4 | nil "foo package" single]) | ||
| 5 | nil | ||
| 6 | (bar . | ||
| 7 | [(1 0) | ||
| 8 | nil "bar package" single])) | ||
diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el index 8670e6f3fac..828c456842a 100644 --- a/test/lisp/emacs-lisp/package-tests.el +++ b/test/lisp/emacs-lisp/package-tests.el | |||
| @@ -452,6 +452,16 @@ Must called from within a `tar-mode' buffer." | |||
| 452 | (search-forward-regexp "^ +simple-single" nil t)))) | 452 | (search-forward-regexp "^ +simple-single" nil t)))) |
| 453 | (if (process-live-p process) (kill-process process))))) | 453 | (if (process-live-p process) (kill-process process))))) |
| 454 | 454 | ||
| 455 | (ert-deftest package-test-update-archives/ignore-nil-entry () | ||
| 456 | "Ignore any packages that are nil. Test for Bug#28502." | ||
| 457 | (with-package-test () | ||
| 458 | (let* ((with-nil-entry (expand-file-name "package-resources/with-nil-entry" | ||
| 459 | package-test-file-dir)) | ||
| 460 | (package-archives `(("with-nil-entry" . ,with-nil-entry)))) | ||
| 461 | (package-initialize) | ||
| 462 | (package-refresh-contents) | ||
| 463 | (should (equal (length package-archive-contents) 2))))) | ||
| 464 | |||
| 455 | (ert-deftest package-test-describe-package () | 465 | (ert-deftest package-test-describe-package () |
| 456 | "Test displaying help for a package." | 466 | "Test displaying help for a package." |
| 457 | 467 | ||