oxygen-git-client-addon
oxygen-git-client-addon copied to clipboard
Run custom commands though JGit CLI
The command line client tools built on top of JGit is available as a Maven artifact: https://mvnrepository.com/artifact/org.eclipse.jgit/org.eclipse.jgit.pgm
What we can do:
- we distribute it along with its dependencies with the plugin, but without putting it in the plugin's classpath
- we add an action that opens a dialog in which the user can write a git command
- from the written command, for example "git status", we take out the "git " prefix and we append the rest to a base command like this:
java -cp args4j-2.33.jar;bcpg-jdk15on-1.61.jar;bcpkix-jdk15on-1.61.jar;bcprov-jdk15on-1.61.jar;eddsa-0.3.0.jar;httpclient-4.5.10.jar;JavaEWAH-1.1.6.jar;jsch-0.1.55.jar;jzlib-1.1.1.jar;log4j-1.2.14.jar;org.eclipse.jgit-5.4.2.201908231537-r.jar;org.eclipse.jgit.http.apache-5.4.2.201908231537-r.jar;org.eclipse.jgit.lfs-5.4.2.201908231537-r.jar;org.eclipse.jgit.pgm-5.4.3.201909031940-r.jar;org.eclipse.jgit.ssh.apache-5.4.2.201908231537-r.jar;slf4j-api-1.7.2.jar;slf4j-log4j12-1.7.25.jar;sshd-common-2.2.0.jar;sshd-core-2.2.0.jar;sshd-osgi-2.2.0.jar;sshd-sftp-2.2.0.jar org.eclipse.jgit.pgm.Main
We might use Maven copy:dependencies to copy all dependencies or https://maven.apache.org/ant-tasks/index.html to collect all these jars.
- we run this command using {{ro.sync.exml.workspace.api.WorkspaceUtilities.startProcess(String, File, String, boolean)}} which will show the output inside the Oxgen's result area.
Some users might desire a Favorites mechanism and/or a History for these commands.
Just so I understand the use cases, how is this different from having an external tool or custom toolbar equivalent that asks the user for a git command or provides a combobox of favorites to choose from and passes it to one of the executeCommand operations? Isn't a separate process created in these instances as well?
Would the JGit command line library allow you to create a git console view that is interactive instead of output only?
On a related note, is the JGit library, or a wrapped version of it, exposed through Oxygen's Rhino engine to Javascript customization scripts?
The main benefit would be that you don't need another git client installed on your system. A separate process would indeed be created in this case as well.
Would the JGit command line library allow you to create a git console view that is interactive instead of output only?
Perhaps, but that's not the scope of this issue.
On a related note, is the JGit library, or a wrapped version of it, exposed through Oxygen's Rhino engine to Javascript customization scripts?
I don't think there's an easy solution to this... These Javascript customization scripts run in a framework action? A framework can share a plugin classloader. In theory, if a framework is bound to the Git plugin's classloader then one could use the singleton {{com.oxygenxml.git.service.GitAccess}} to execute operations on the Git repository etc.
I gave it a shot and unfortunately the JS script doesn't look to be invoked in the framework's class loader which means it can't access git plugin classes. That leaves the JAVA based operation which is definitely loaded with the proper class loader so it can access the git classes.