Skip to content

Commit

Permalink
fix: Fix to handle :git/url when scanning transitive deps
Browse files Browse the repository at this point in the history
cf. #225
  • Loading branch information
liquidz committed Jun 17, 2023
1 parent bac2568 commit 7ce9291
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/antq/dep/transitive.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,20 @@

(defmethod dep->dep-map :git-sha
[dep]
{(symbol (:name dep))
{:git/sha (:version dep)}})
(let [extra-url (get-in dep [:extra :url])]
{(symbol (:name dep))
(cond-> {:git/sha (:version dep)}
(seq extra-url)
(assoc :git/url extra-url))}))

(defmethod dep->dep-map :git-tag-and-sha
[dep]
{(symbol (:name dep))
{:git/tag (:version dep)
:git/sha (get-in dep [:extra :sha])}})
(let [extra-url (get-in dep [:extra :url])]
{(symbol (:name dep))
(cond-> {:git/tag (:version dep)
:git/sha (get-in dep [:extra :sha])}
(seq extra-url)
(assoc :git/url extra-url))}))

;; ===== resolved-dep->dep =====
(defn- parent-name
Expand Down
35 changes: 35 additions & 0 deletions test/antq/dep/transitive_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,41 @@
:dependents ['foo/bob]}}
{}))

(t/deftest dep->dep-map-test
(t/testing "java"
(t/is (= {'foo/bar {:mvn/version "1.2.3"}}
(#'sut/dep->dep-map {:type :java
:name "foo/bar"
:version "1.2.3"}))))
(t/testing "git-sha with git/url"
(t/is (= {'foo/bar {:git/sha "86eddb89f2a2018fd984dffaadfec13e6735e92f"
:git/url "https://github.com/liquidz/antq"}}
(#'sut/dep->dep-map {:type :git-sha
:name "foo/bar"
:version "86eddb89f2a2018fd984dffaadfec13e6735e92f"
:extra {:url "https://github.com/liquidz/antq"}}))))
(t/testing "git-sha without git/url"
(t/is (= {'com.github.liquidz/antq {:git/sha "86eddb89f2a2018fd984dffaadfec13e6735e92f"}}
(#'sut/dep->dep-map {:type :git-sha
:name "com.github.liquidz/antq"
:version "86eddb89f2a2018fd984dffaadfec13e6735e92f"}))))
(t/testing "git-tag-and-sha with git/url"
(t/is (= {'foo/bar {:git/tag "1.2.3"
:git/sha "86eddb8"
:git/url "https://github.com/liquidz/antq"}}
(#'sut/dep->dep-map {:type :git-tag-and-sha
:name "foo/bar"
:version "1.2.3"
:extra {:sha "86eddb8"
:url "https://github.com/liquidz/antq"}}))))
(t/testing "git-tag-and-sha without git/url"
(t/is (= {'com.github.liquidz/antq {:git/tag "1.2.3"
:git/sha "86eddb8"}}
(#'sut/dep->dep-map {:type :git-tag-and-sha
:name "com.github.liquidz/antq"
:version "1.2.3"
:extra {:sha "86eddb8"}})))))

(t/deftest resolve-transitive-deps-test
(with-redefs [deps/resolve-deps mock-resolve-deps]
(t/is (= [(r/map->Dependency {:type :java
Expand Down

0 comments on commit 7ce9291

Please sign in to comment.