ProgressMonitor gitMonitor = new EclipseGitProgressTransformer(monitor);
Repository db = null;
try {
db = FileRepositoryBuilder.create(GitUtils.getGitDir(path));
Git git = new Git(db);
PullCommand pc = git.pull();
pc.setProgressMonitor(gitMonitor);
pc.setCredentialsProvider(credentials);
pc.setTransportConfigCallback(new TransportConfigCallback() {
@Override
public void configure(Transport t) {
credentials.setUri(t.getURI());
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);
}
}
});
PullResult pullResult = pc.call();
if (monitor.isCanceled()) {
return new Status(IStatus.CANCEL, GitActivator.PI_GIT, "Cancelled");
}