Hi everyone,
I would like to know if anyone has already tried to use JGit (the git library for java) in a java snippet.
I am planning to use it because I need to manage git submodules within my workflows and the available “Git nodes” extension is too basic for such tasks.
I’m new to java but willing to learn.
Thanks,
Dimitri
I have been able to import jgit classes by loading the additional bundle org.eclipse.jgit 5.11.0.202103091610-r
but my expression CloneRepo();
(last line of the code below) is highlighted with the following message :
Unhandled exception type org.eclipse.jgit.api.errors.InvalidRemoteException
Any help would be warmly welcomed…
Here is the copy of the snippet content :
// system imports
import org.knime.base.node.jsnippet.expression.AbstractJSnippet;
import org.knime.base.node.jsnippet.expression.Abort;
import org.knime.base.node.jsnippet.expression.Cell;
import org.knime.base.node.jsnippet.expression.ColumnException;
import org.knime.base.node.jsnippet.expression.TypeException;
import static org.knime.base.node.jsnippet.expression.Type.*;
import java.util.Date;
import java.util.Calendar;
import org.w3c.dom.Document;
// Your custom imports:
import java.io.File;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.InvalidRemoteException;
import org.eclipse.jgit.api.errors.TransportException;
// system variables
public class JSnippet extends AbstractJSnippet {
// Your custom variables:
public static void CloneRepo() throws InvalidRemoteException, TransportException, GitAPIException {
Git.cloneRepository()
.setURI("https://github.com/github/opensource.guide.git")
.setDirectory(new File("/path/to/targetdirectory"))
.call();
}
// expression start
public void snippet() throws TypeException, ColumnException, Abort {
// Enter your code here:
CloneRepo();
// expression end
}
}
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.