javahttpjgit:如何使用JGIT实现push操作
错误: org.eclipse.jgit.api.errors.TransportException::411所需长度 位于org.eclipse.jgit.api.PushCommand.call(PushCommand.java:147) 如果我尝试以同样的方式克隆存储库,它就可以正常工作 我的代码:javahttpjgit:如何使用JGIT实现push操作,java,git,http,push,jgit,Java,Git,Http,Push,Jgit,错误: org.eclipse.jgit.api.errors.TransportException::411所需长度 位于org.eclipse.jgit.api.PushCommand.call(PushCommand.java:147) 如果我尝试以同样的方式克隆存储库,它就可以正常工作 我的代码: public void testPush() throws IOException, GitAPIException { Path clonePath = Files
public void testPush() throws IOException, GitAPIException {
Path clonePath = Files.createTempDirectory(REPOSITORY_NAME);
// Clone repository: working fine
Git git =
cloneRepository(
repository, clonePath, "refs/heads/master");
Path textPath = Paths.get(clonePath.toString(), "text1.txt");
createBlobOfVariableSize(textPath, 100);
git.add().addFilepattern(".").call();
git.commit().setMessage("test").call();
Iterable<PushResult> pushResults =
pushRepository(git, "refs/heads/master");
for (PushResult pushResult : pushResults) {
Assertions.assertFalse(pushResult.isEmpty());
}
}
public Iterable<PushResult> pushRepository(Git git, String branchName) throws
GitAPIException {
RefSpec spec = new RefSpec(branchName);
Iterable<PushResult> rev =
git.push()
.setPushTags()
.setRefSpecs(spec)
.setCredentialsProvider(
new UsernamePasswordCredentialsProvider(
"username", "password"))
.call();
return rev;
}
public void testPush()抛出IOException、GitAPIException{
路径clonePath=Files.createTempDirectory(存储库名称);
//克隆存储库:工作正常
吉特吉特=
克隆定位(
知识库,clonePath,“参考/主管/主管”);
Path textPath=Path.get(clonePath.toString(),“text1.txt”);
createBlobOfVariableSize(textPath,100);
git.add().addFilepattern(“.”.call();
git.commit().setMessage(“test”).call();
可编辑的结果=
pushRepository(git,“参考/主管/主管”);
用于(PushResult PushResult:pushResults){
assertFalse(pushResult.isEmpty());
}
}
公共Iterable pushRepository(Git-Git,String-branchName)抛出
GitAPIException{
RefSpec spec=新的RefSpec(branchName);
可调转速=
git.push()
.setPushTags()
.SETREF规范(规范)
.setCredentialsProvider(
新用户名PasswordCredentialsProvider(
“用户名”、“密码”))
.call();
返回版本;
}
根据这篇文章,服务器错误“411 Length Required”表示您试图推动大量更改: