Welcome! Please see the About page for a little more info on how this works.

+1 vote
in tools.gitlibs by

tools.gitlibs cannot fetch Git SHA1s that aren't included on a branch. For example, if a commit is only referenced by a tag (e.g., v1.2.3-acme1), then clj -Spath fails with the following error:

Error building classpath. Missing unknown fb8143248fddb5177de6eb55ed21956782776c4a
org.eclipse.jgit.api.errors.JGitInternalException: Missing unknown fb8143248fddb5177de6eb55ed21956782776c4a

Would it be possible to update tools.gitlibs with the following patch?

---
 src/main/clojure/clojure/tools/gitlibs/impl.clj | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/main/clojure/clojure/tools/gitlibs/impl.clj b/src/main/clojure/clojure/tools/gitlibs/impl.clj
index b2eba18..a2ee828 100644
--- a/src/main/clojure/clojure/tools/gitlibs/impl.clj
+++ b/src/main/clojure/clojure/tools/gitlibs/impl.clj
@@ -17,7 +17,7 @@
     [org.eclipse.jgit.api Git GitCommand TransportCommand TransportConfigCallback]
     [org.eclipse.jgit.lib Repository RepositoryBuilder]
     [org.eclipse.jgit.revwalk RevWalk RevCommit]
-    [org.eclipse.jgit.transport SshTransport JschConfigSessionFactory]
+    [org.eclipse.jgit.transport SshTransport JschConfigSessionFactory TagOpt]
     [com.jcraft.jsch JSch]
     [com.jcraft.jsch.agentproxy Connector ConnectorFactory RemoteIdentityRepository]))
 
@@ -63,7 +63,7 @@
 (defn git-fetch
   ^Git [git-dir]
   (let [git (Git. (git-repo git-dir))]
-    (call-with-auth (.. git fetch))
+    (call-with-auth (.. git fetch (setTagOpt TagOpt/FETCH_TAGS)))
     git))
 
 ;; TODO: restrict clone to an optional refspec?
@@ -74,7 +74,8 @@
     (.. (Git/cloneRepository) (setURI url) (setGitDir (jio/file git-dir))
       (setBare true)
       (setNoCheckout true)
-      (setCloneAllBranches true)))
+      (setCloneAllBranches true)
+      (setTagOption TagOpt/FETCH_TAGS)))
   git-dir)

1 Answer

0 votes
by

Can you give me a reproducible case on a public repo or how to set one up so I can test? Happy to add...

by
nvm, I got it
by
I found the second change is actually not a method that exists yet at the jgit version we're on and bumping to later is quite a bit more work that I don't want to do at the moment. It also does not appear to be necessary so I've just left that out. In process to release tools.gitlibs 1.0.100 with the change and that will get into next releases of tools.deps and clj.
by
Thanks for the fast reply and fix!
...