try {
File cloneFolder = new File(clone.getContentLocation().getPath());
if (!cloneFolder.exists()) {
cloneFolder.mkdir();
}
CloneCommand cc = Git.cloneRepository();
cc.setProgressMonitor(gitMonitor);
cc.setBare(false);
cc.setCredentialsProvider(credentials);
cc.setDirectory(cloneFolder);
cc.setRemote(Constants.DEFAULT_REMOTE_NAME);
cc.setURI(clone.getUrl());
if (this.cookie != null) {
cc.setTransportConfigCallback(new TransportConfigCallback() {
@Override
public void configure(Transport t) {
if (t instanceof TransportHttp && cookie != null) {
HashMap<String, String> map = new HashMap<String, String>();
map.put(GitConstants.KEY_COOKIE, cookie.getName() + "=" + cookie.getValue());
((TransportHttp) t).setAdditionalHeaders(map);
}
}
});
}
Git git = cc.call();
if (monitor.isCanceled()) {
return new Status(IStatus.CANCEL, GitActivator.PI_GIT, "Cancelled");
}
// Configure the clone, see Bug 337820