1
JGit을 사용하여 사용자 정의 git-push ant 태스크를 완료하려고 시도했으나 명시된 분기를 원격 저장소로 푸시해야하지만 작동하지 않는 것으로 보입니다.사용자 정의 git push ant task가 JGit에서 작동하지 않습니다.
다음은 작업에 대한 내 자바 코드입니다 :
public void setRepository(String repository) {
this.repository = repository;
}
public void setPassword(String password) {
this.password = password;
}
public void setUsername(String username) {
this.username = username;
}
public void setUri(String uri) {
this.uri = uri;
}
public void setBranch(String branch) {
this.branch = branch;
}
public void execute() throws BuildException {
try{
Git git = Git.open(new File(repository));
CredentialsProvider cp = new UsernamePasswordCredentialsProvider(username, password);
RefSpec spec = new RefSpec("refs/heads/" + branch + ":refs/heads/" + branch);
PushCommand pushCommand = git.push();
pushCommand.setCredentialsProvider(cp).setRemote(uri).setForce(true).setRefSpecs(spec).call();
}catch (Exception e) {
log(e, Project.MSG_ERR);
throw new BuildException("Could not push repository: " + e.getMessage(), e);
}
그리고 여기에 아파치 개미 빌드 파일에서 줄입니다 :
<gitpush
repository="./myrepo"
uri="ssh://[email protected]/repo/project.git"
branch="mybranch"
password="77CJr2xr" />
내가 새로운 지점을 생성하고이 작업을 실행 해보십시오. 태스크는 예외없이 실행되지만 원격 저장소에는 영향을 미치지 않습니다. 나는 정말 어리석은 실수 일 수 있기 때문에 자식에게는 아주 새로운 것이다. RefSpec에 문제가 있습니까?
'PushCommand # call()'은'PushResult'를 리턴하고,'PushResult'는'RemoteRefUpdate' 콜렉션을 보유합니다. 이걸 조사 했니? 그들은 당신에게 밀어 넣기가 실제로 한 단서를 제공해야합니다. –
나는 메시지를 받는다 :'error : 정체를 밝히지 않는 ref/head/mybranch를 부정하라. 어쩌면 나는'git checkout --orphan mybranch'을'git rm --cached -r .'과 함께 사용하여 새로운 빈 브랜치를 생성 한 다음 그 파일을 추가함으로써 뭔가 잘못 됐을 까? – JulioBordeaux