I am developing an Eclipse plugin which users can log in through this plugin and use some git repositories (through ssh and with user/password credentials) which are accessed behind the curtains. Users do not know their ssh passwords.
These users have read only access to a git repository. When one of the users logs in on a computer for the first time, the git is pulled on to the local machine. There is no problem so far. When user logs out, for the efficiency I want to keep this local copy on this machine. And my problem starts at this point.
When another user logs in, I retrieve the git object from the local copy and unfortunately (for me), it includes the URI which is set for the first user.
Is there a way to set the URI of a org.eclipse.jgit.api.Git object.
I try the following code with no success. Setting URI thii way throws org.eclipse.jgit.api.errors.InvalidConfigurationException: No value for key remote
This code (without setting URI) works as expected for the same user. And it updates the local copy from remote.
Git git = Git.open(new File("PATH" + "/.git"));
git.pull()
.setTransportConfigCallback(new TransportConfigCallback() {
@Override
public void configure( Transport transport ) {
if( transport instanceof SshTransport ) {
SshTransport sshTransport = ( SshTransport )transport;
sshTransport.setSshSessionFactory(new JschConfigSessionFactory() {
@Override
protected void configure(Host hc, Session session) {
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
session.setConfig(config);
session.setPassword("password");
}
});
}
}
})
.setRemote(remoteURI)
.call();