2017-07-19 4 views
2

ここでの問題は、URLがリダイレクトされ、JGitでは処理されないことです。同じことが報告されたバグはありません。解決されたと言われていますが、私はまだこの問題に直面しています。私が何か悪いことをしているかどうか教えてください。http URLのJGitを使用してリモートリポジトリを複製できない

コードスニペット

private static Git cloneRepository(String url, String branch, String targetPath) throws IOException { 
    Git result = null; 
    try { 
     CloneCommand cloneCommand = Git.cloneRepository().setCloneSubmodules(true) 
             .setURI(url).setBranch(branch) 
             .setCloneSubmodules(true) 
             .setDirectory(new File(targetPath)); 
     result = cloneCommand.call(); 
    } catch (GitAPIException e) { 
     e.printStackTrace(); 
    } 
    return result; 
} 

public static void main(String[] args) throws IOException { 
    cloneRepository("http://github.com/google/mathfu", "master", "D:/codebase"); 
    //cloneRepository("https://github.com/google/mathfu", "master", "D:/codebase"); 
} 

例外次のコード


//cloneRepository("http://github.com/google/mathfu", "master", "D:/codebase"); 
cloneRepository("https://github.com/google/mathfu", "master", "D:/codebase"); 

例外を変更した後のコード

org.eclipse.jgit.api.errors.TransportException: 'http://github.com/google/mathfu': 301 Moved Permanently 
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:245) 
at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:293) 
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:190) 
at com.acellere.demo.GitDemo.App.cloneRepository(App.java:21) 
at com.acellere.demo.GitDemo.App.main(App.java:31) 
Caused by: org.eclipse.jgit.errors.TransportException: 'http://github.com/google/mathfu': 301 Moved Permanently 
at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:545) 
at org.eclipse.jgit.transport.TransportHttp.openFetch(TransportHttp.java:326) 
at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136) 
at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122) 
at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1236) 
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:234) 
... 4 more 

を実行した後

org.eclipse.jgit.api.errors.TransportException: 'http://github.com/google/fplutil.git': 301 Moved Permanently 
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:245) 
at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:293) 
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:190) 
at org.eclipse.jgit.api.SubmoduleUpdateCommand.call(SubmoduleUpdateCommand.java:177) 
at org.eclipse.jgit.api.CloneCommand.cloneSubmodules(CloneCommand.java:372) 
at org.eclipse.jgit.api.CloneCommand.checkout(CloneCommand.java:353) 
at org.eclipse.jgit.api.CloneCommand.call(CloneCommand.java:215) 
at com.acellere.demo.GitDemo.App.cloneRepository(App.java:16) 
at com.acellere.demo.GitDemo.App.main(App.java:25) 
Caused by: org.eclipse.jgit.errors.TransportException: 'http://github.com/google/fplutil.git': 301 Moved Permanently 
at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:545) 
at org.eclipse.jgit.transport.TransportHttp.openFetch(TransportHttp.java:326) 
at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:136) 
at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:122) 
at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1236) 
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:234) 
... 8 more 

詳細:https://git.eclipse.org/r/#/c/46261/、2月に合併した次のJGitバージョン 4.8.0.201706111038-R

を使用して

があまりにも

答えて

1

この変更に伴いバージョン4.4.x.xxxxxてみました2017、JGitはHTTP 301のステータスコード(永続的に移動)に従うことができるはずです。

ただし、CloneCommandはまだ動作していないようです。コードスニペットがTransportExceptionをスローすることを確認できます。

対応するバグレポートは、ここで見つけることができます:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=465167 https://bugs.eclipse.org/bugs/show_bug.cgi?id=474094

私はこの記事を指すバグレポートにコメントを追加しました。

アップデート2017年8月18日:バグが固定されており、私の元の答えは非常に適切ではありませんでした@aoswal、更新の答えを参照してください。JGit 4.9

+0

にリリースされます。 –

関連する問題