tools.gitlibs
无法获取不在分支上的 Git SHA1。例如,如果一个提交只被标签引用(例如,v1.2.3-acme1),那么运行 clj -Spath
将出现以下错误:
Error building classpath. Missing unknown fb8143248fddb5177de6eb55ed21956782776c4a
org.eclipse.jgit.api.errors.JGitInternalException: Missing unknown fb8143248fddb5177de6eb55ed21956782776c4a
能否用以下补丁更新 tools.gitlibs?
---
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)