File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed
src/main/clojure/clojure/tools Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 1
1
Changelog
2
2
===========
3
3
4
+ * next
5
+ * Add new ` object-type ` api - takes rev, returns object type
4
6
* 2.2.156 on Apr 7, 2021
5
7
* ` tags ` api should fetch to ensure all tags are returned
6
8
* 2.2.152 on Apr 3, 2021
Original file line number Diff line number Diff line change 47
47
[url rev]
48
48
(first (resolve-all url [rev])))
49
49
50
+ (defn object-type
51
+ " Takes a git url and rev, and returns the object type, one of :tag :tree
52
+ :commit or :blob, or nil if not known or ambiguous."
53
+ [url rev]
54
+ (let [git-dir (impl/ensure-git-dir url)]
55
+ (if-let [type (impl/git-type git-dir rev)]
56
+ type
57
+ (do
58
+ (impl/git-fetch (jio/file git-dir))
59
+ (impl/git-type git-dir rev)))))
60
+
50
61
(defn procure
51
62
" Procure a working tree at rev for the git url representing the library lib,
52
63
returns the directory path. lib is a qualified symbol where the qualifier is a
Original file line number Diff line number Diff line change 102
102
(when (zero? exit)
103
103
(str/trimr out))))
104
104
105
+ (defn git-type
106
+ [git-dir rev]
107
+ (let [{:keys [exit out]} (run-git " --git-dir" git-dir " cat-file" " -t" rev)]
108
+ (when (zero? exit)
109
+ (keyword (str/trimr out)))))
110
+
105
111
; ; git merge-base --is-ancestor <maybe-ancestor-commit> <descendant-commit>
106
112
(defn- ancestor?
107
113
[git-dir x y]
You can’t perform that action at this time.
0 commit comments