From 88b354e80ae5ca35a1574927f32c7831eaccb5f5 Mon Sep 17 00:00:00 2001 From: liquidz Date: Sun, 7 Apr 2024 06:32:26 +0900 Subject: [PATCH 1/7] fix: Fix to be able to upgrade deps in namespaced map cf. #251 --- src/antq/upgrade/clojure.clj | 16 ++++++++++++++-- test/antq/upgrade/clojure_test.clj | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/antq/upgrade/clojure.clj b/src/antq/upgrade/clojure.clj index d22fad56..99cba7bf 100644 --- a/src/antq/upgrade/clojure.clj +++ b/src/antq/upgrade/clojure.clj @@ -7,10 +7,22 @@ [antq.util.zip :as u.zip] [rewrite-clj.zip :as z])) +(defn- in-namespaced-map? + [loc] + (boolean + (some-> loc + z/up + z/leftmost + z/up + z/namespaced-map?))) + (defn- in-deps? [loc] - (->> loc z/up z/left z/sexpr - (contains? const/clojure-deps-keys))) + (if (in-namespaced-map? loc) + (->> loc z/up z/leftmost z/up z/left z/sexpr + (contains? const/clojure-deps-keys)) + (->> loc z/up z/left z/sexpr + (contains? const/clojure-deps-keys)))) (defn- skip-meta [loc] diff --git a/test/antq/upgrade/clojure_test.clj b/test/antq/upgrade/clojure_test.clj index 1771d891..2555117d 100644 --- a/test/antq/upgrade/clojure_test.clj +++ b/test/antq/upgrade/clojure_test.clj @@ -90,6 +90,12 @@ :file (io/resource "dep/test_deps.edn") :extra {:sha "123abcd"}})) +(defn- select-deps [name-pred file] + (->> (slurp file) + (dep.clj/extract-deps "") + (filter #(name-pred (:name %))) + (map #(assoc % :file file)))) + (t/deftest upgrade-dep-test (t/testing "java" (let [from-deps (->> dummy-java-dep @@ -276,3 +282,12 @@ (dep.clj/extract-deps ""))] (t/is (= #{{:name "dft/dft" :version {:- "6.0.0" :+ "9.0.0"}}} (h/diff-deps from-deps to-deps))))) + +(t/deftest upgrade-dep-namespaced-java-deps-test + (let [from-deps (->> (io/resource "dep/test_deps_namespaced_map.edn") + (select-deps #{"foo/bar"})) + to-deps (->> (assoc (first from-deps) :latest-version "9.0.0") + (upgrade/upgrader) + (dep.clj/extract-deps ""))] + (t/is (= #{{:name "foo/bar" :version {:- "1.0.0" :+ "9.0.0"}}} + (h/diff-deps from-deps to-deps))))) From 4e868dc29d8b016707b12023e25eccb5b34bbfa0 Mon Sep 17 00:00:00 2001 From: liquidz Date: Sun, 7 Apr 2024 06:43:16 +0900 Subject: [PATCH 2/7] deps: Bump clojure to 1.11.2 --- deps.edn | 2 +- test/resources/integration-testing/green/project.clj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deps.edn b/deps.edn index 06dbea9f..6d69b65e 100644 --- a/deps.edn +++ b/deps.edn @@ -1,6 +1,6 @@ {:paths ["src"] :deps - {org.clojure/clojure {:mvn/version "1.11.1"} + {org.clojure/clojure {:mvn/version "1.11.2"} org.clojure/data.xml {:mvn/version "0.2.0-alpha9"} org.clojure/data.zip {:mvn/version "1.1.0"} org.clojure/tools.cli {:mvn/version "1.1.230"} diff --git a/test/resources/integration-testing/green/project.clj b/test/resources/integration-testing/green/project.clj index a74f6ef2..a5efd802 100644 --- a/test/resources/integration-testing/green/project.clj +++ b/test/resources/integration-testing/green/project.clj @@ -1,7 +1,7 @@ (defproject green "n/a" :description "Please keep me updated - `lein antq` should pass for this project" :managed-dependencies [[com.stuartsierra/dependency "1.0.0"]] - :dependencies [[org.clojure/clojure "1.11.1"] + :dependencies [[org.clojure/clojure "1.11.2"] [com.stuartsierra/dependency]] :plugins [[lein-pprint "1.3.2"] [com.github.liquidz/antq "RELEASE"]] From 60854ecda0f4eef86e78a43ede4fcd45e3c12991 Mon Sep 17 00:00:00 2001 From: liquidz Date: Sun, 7 Apr 2024 06:43:41 +0900 Subject: [PATCH 3/7] deps: Bump tools.deps to 0.19.1417 --- deps.edn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps.edn b/deps.edn index 6d69b65e..01fff105 100644 --- a/deps.edn +++ b/deps.edn @@ -5,7 +5,7 @@ org.clojure/data.zip {:mvn/version "1.1.0"} org.clojure/tools.cli {:mvn/version "1.1.230"} org.clojure/core.async {:mvn/version "1.6.681"} - org.clojure/tools.deps {:mvn/version "0.18.1398"} + org.clojure/tools.deps {:mvn/version "0.19.1417"} org.clojure/data.json {:mvn/version "2.5.0"} clj-commons/clj-yaml {:mvn/version "1.0.27"} version-clj/version-clj {:mvn/version "2.0.2"} From ada3d006a220ec760a9135582daf9573c37008b6 Mon Sep 17 00:00:00 2001 From: liquidz Date: Sun, 7 Apr 2024 06:44:06 +0900 Subject: [PATCH 4/7] deps: Bump dev dependencies --- deps.edn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deps.edn b/deps.edn index 01fff105..74a7a7b4 100644 --- a/deps.edn +++ b/deps.edn @@ -24,8 +24,8 @@ {:extra-paths ["dev" "test" "test/resources"] - :extra-deps {metosin/malli {:mvn/version "0.14.0"} - lambdaisland/kaocha {:mvn/version "1.87.1366"} + :extra-deps {metosin/malli {:mvn/version "0.15.0"} + lambdaisland/kaocha {:mvn/version "1.88.1376"} lambdaisland/deep-diff2 {:mvn/version "2.11.216"}} :jvm-opts ["-Dclojure.core.async.go-checking=true"]} From 3c54dd9bd55f4f706db9577a53729339f2da558d Mon Sep 17 00:00:00 2001 From: liquidz Date: Sun, 7 Apr 2024 06:49:15 +0900 Subject: [PATCH 5/7] style: Fix formatting error --- src/antq/upgrade/clojure.clj | 10 +++++----- test/antq/upgrade/clojure_test.clj | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/antq/upgrade/clojure.clj b/src/antq/upgrade/clojure.clj index 99cba7bf..cf92f2c6 100644 --- a/src/antq/upgrade/clojure.clj +++ b/src/antq/upgrade/clojure.clj @@ -10,11 +10,11 @@ (defn- in-namespaced-map? [loc] (boolean - (some-> loc - z/up - z/leftmost - z/up - z/namespaced-map?))) + (some-> loc + z/up + z/leftmost + z/up + z/namespaced-map?))) (defn- in-deps? [loc] diff --git a/test/antq/upgrade/clojure_test.clj b/test/antq/upgrade/clojure_test.clj index 2555117d..1047900a 100644 --- a/test/antq/upgrade/clojure_test.clj +++ b/test/antq/upgrade/clojure_test.clj @@ -90,7 +90,8 @@ :file (io/resource "dep/test_deps.edn") :extra {:sha "123abcd"}})) -(defn- select-deps [name-pred file] +(defn- select-deps + [name-pred file] (->> (slurp file) (dep.clj/extract-deps "") (filter #(name-pred (:name %))) From 2f372874cc85a8e1c2afa5cf95e441cac4df1eed Mon Sep 17 00:00:00 2001 From: liquidz Date: Sun, 7 Apr 2024 06:52:37 +0900 Subject: [PATCH 6/7] test: Add test resource --- test/resources/dep/test_deps_namespaced_map.edn | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 test/resources/dep/test_deps_namespaced_map.edn diff --git a/test/resources/dep/test_deps_namespaced_map.edn b/test/resources/dep/test_deps_namespaced_map.edn new file mode 100644 index 00000000..bfa6ca54 --- /dev/null +++ b/test/resources/dep/test_deps_namespaced_map.edn @@ -0,0 +1,8 @@ +{:deps #:foo{bar #:mvn{:version "1.0.0"} + git-sha #:git{:url "https://github.com/example/git-sha.git" + :sha "dummy-git-sha"} + git-tag-long-sha #:git{:url "https://github.com/example/git-tag-long.git" + :tag "v2.3.4" + :sha "1234567890abcdefghijklmnopqrstuvwxyz1234"} + + local-repo/local-repo #:local{:root "./local"}}} From aefcac67e3356f65e585e1385a0682a6d6a7f97b Mon Sep 17 00:00:00 2001 From: liquidz Date: Sun, 7 Apr 2024 07:12:52 +0900 Subject: [PATCH 7/7] docs: Update CHANGELOG --- CHANGELOG.adoc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 3d75cd9e..04a45710 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -1,6 +1,16 @@ All notable changes to this project will be documented in this file. This change log follows the conventions of http://keepachangelog.com/[keepachangelog.com]. == Unreleased (dev) +// {{{ +=== Changed +* Bumped clojure to 1.11.2. +* Bumped tools.deps to 0.19.1417. +* Bumped malli to 0.15.0. +* Bumped kaocha to 1.88.1376. + +=== Fixed +* https://github.com/liquidz/antq/issues/251[#251]: Fixed clojure upgrader to be able to upgrade deps in namespaced map. +// }}} == 2.8.1185 (2024-02-23) // {{{