emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/cider 956984faa1: `cider-clojure-cli-jack-in-dependencies`


From: ELPA Syncer
Subject: [nongnu] elpa/cider 956984faa1: `cider-clojure-cli-jack-in-dependencies`: always remove duplicates (#3155)
Date: Mon, 21 Feb 2022 09:58:09 -0500 (EST)

branch: elpa/cider
commit 956984faa1f8a5edc9eb94eacdf530cb9404850b
Author: vemv <vemv@users.noreply.github.com>
Commit: GitHub <noreply@github.com>

    `cider-clojure-cli-jack-in-dependencies`: always remove duplicates (#3155)
    
    Prevents all sorts of issues, particularly as this area is changing as of 
lately.
---
 cider.el            | 17 +++++++++++------
 test/cider-tests.el |  9 +++++++++
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/cider.el b/cider.el
index b209dd476d..994c3ee64c 100644
--- a/cider.el
+++ b/cider.el
@@ -608,17 +608,22 @@ removed, LEIN-PLUGINS, LEIN-MIDDLEWARES and finally 
PARAMS."
    " -- "
    params))
 
+(defun cider--dedupe-deps (deps)
+  (cl-delete-duplicates deps :test 'equal))
+
 (defun cider-clojure-cli-jack-in-dependencies (global-options _params 
dependencies)
   "Create Clojure tools.deps jack-in dependencies.
 Does so by concatenating DEPENDENCIES and GLOBAL-OPTIONS into a suitable
 `clojure` invocation.  The main is placed in an inline alias :cider/nrepl
 so that if your aliases contain any mains, the cider/nrepl one will be the
 one used."
-  (let* ((deps-string (string-join
-                       (seq-map (lambda (dep)
-                                  (format "%s {:mvn/version \"%s\"}" (car dep) 
(cadr dep)))
-                                (append (cider--jack-in-required-dependencies) 
dependencies))
-                       " "))
+  (let* ((all-deps (thread-last dependencies
+                     (append (cider--jack-in-required-dependencies))
+                     ;; Duplicates are never OK since they would result in
+                     ;; `java.lang.IllegalArgumentException: Duplicate key 
[...]`:
+                     (cider--dedupe-deps)
+                     (seq-map (lambda (dep)
+                                (format "%s {:mvn/version \"%s\"}" (car dep) 
(cadr dep))))))
          (middleware (mapconcat
                       (apply-partially #'format "%s")
                       (cider-jack-in-normalized-nrepl-middlewares)
@@ -626,7 +631,7 @@ one used."
          (main-opts (format "\"-m\" \"nrepl.cmdline\" \"--middleware\" 
\"[%s]\"" middleware)))
     (format "%s-Sdeps '{:deps {%s} :aliases {:cider/nrepl {:main-opts [%s]}}}' 
-M%s:cider/nrepl"
             (if global-options (format "%s " global-options) "")
-            deps-string
+            (string-join all-deps " ")
             main-opts
             (if cider-clojure-cli-aliases
                 ;; remove exec-opts flags -A -M -T or -X from 
cider-clojure-cli-aliases
diff --git a/test/cider-tests.el b/test/cider-tests.el
index 95eadbbe00..93369ff76d 100644
--- a/test/cider-tests.el
+++ b/test/cider-tests.el
@@ -425,6 +425,15 @@
         (spy-on 'cider-jack-in-resolve-command :and-return-value "clojure")
         (expect (plist-get (cider--update-jack-in-cmd nil) :jack-in-cmd)
                 :to-equal expected)))
+    (let ((expected (string-join '("-Sdeps '{:deps {nrepl/nrepl {:mvn/version 
\"0.9.0\"} "
+                                   "cider/cider-nrepl {:mvn/version 
\"0.28.1\"}} "
+                                   ":aliases {:cider/nrepl {:main-opts [\"-m\" 
\"nrepl.cmdline\" \"--middleware\""
+                                   " \"[cider.nrepl/cider-middleware]\"]}}}' 
-M:cider/nrepl")
+                                 "")))
+      (describe "should remove duplicates, yielding the same result"
+                (expect (cider-clojure-cli-jack-in-dependencies nil nil 
'(("nrepl/nrepl" "0.9.0")
+                                                                          
("nrepl/nrepl" "0.9.0")))
+                        :to-equal expected)))
     (it "handles aliases correctly"
       (let ((expected (string-join '("-Sdeps '{:deps {nrepl/nrepl 
{:mvn/version \"0.9.0\"} "
                                      "cider/cider-nrepl {:mvn/version 
\"0.28.1\"}} "



reply via email to

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