Skip to content

Commit 6feba28

Browse files
committed
TDEPS-248 - Make tags return known tags when offline
1 parent d3052a4 commit 6feba28

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Changelog
22
===========
33

4+
* next
5+
* TDEPS-248 - Make `tags` return known tags when offline
46
* 2.5.190 on Feb 12, 2023
57
* Don't use future to background the process reading (leaves non-daemon thread)
68
* 2.5.186 on Feb 11, 2023

src/main/clojure/clojure/tools/gitlibs/impl.clj

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@
101101
^File [url]
102102
(jio/file (:gitlibs/dir @config/CONFIG) "_repos" (clean-url url)))
103103

104+
(defn git-try-fetch
105+
"Try to fetch and return the error code (0=success)"
106+
[^File git-dir]
107+
(let [git-path (.getCanonicalPath git-dir)
108+
;; NOTE: --prune-tags would be desirable here but was added in git 2.17.0
109+
{:keys [exit]} (run-git "--git-dir" git-path
110+
"fetch" "--quiet" "--all" "--tags" "--prune")]
111+
exit))
112+
104113
(defn git-fetch
105114
[^File git-dir]
106115
(let [git-path (.getCanonicalPath git-dir)
@@ -193,7 +202,7 @@
193202
(defn tags
194203
"Fetch, then return all tags in the git dir."
195204
[git-dir]
196-
(git-fetch (jio/file git-dir))
205+
(git-try-fetch (jio/file git-dir))
197206
(let [{:keys [exit out err] :as ret} (run-git "--git-dir" git-dir "tag" "--sort=v:refname")]
198207
(when-not (zero? exit)
199208
(throw (ex-info (format "Unable to get tags %s%n%s" git-dir err) ret)))

0 commit comments

Comments
 (0)