summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm.test/tst/org
diff options
context:
space:
mode:
authorAndre Bossert <andre.bossert@siemens.com>2020-01-19 20:56:28 +0100
committerAndrey Loskutov <loskutov@gmx.de>2022-06-01 14:23:48 +0200
commit973e955ead1a9bf41efb3168baf5b68527e78023 (patch)
tree70e6b916308e20da790ac41759e1b9bd3c28b324 /org.eclipse.jgit.pgm.test/tst/org
parentbb30be6b3335c67ee59d3705d5e04e2dbb688128 (diff)
downloadjgit-973e955ead1a9bf41efb3168baf5b68527e78023.tar.gz
jgit-973e955ead1a9bf41efb3168baf5b68527e78023.zip
Add availability check of pre-defined tools
see: https://git-scm.com/docs/git-difftool see: https://git-scm.com/docs/git-mergetool * now all available tools are printed with "--tool-help" * if no diff.tool or merge.tool is defined the first available pre-defined tool is used TODO: - add mergetools to difftools --> extra change or merge to this - return the exit-code of the tool to jgit / java runtime Bug: 356832 Change-Id: I20fb04e71ced981f5625020f461bbac24e6cec70 Signed-off-by: Andre Bossert <andre.bossert@siemens.com>
Diffstat (limited to 'org.eclipse.jgit.pgm.test/tst/org')
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DiffToolTest.java30
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/MergeToolTest.java30
2 files changed, 50 insertions, 10 deletions
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DiffToolTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DiffToolTest.java
index 8daaa6ad9e..a258821f0c 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DiffToolTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/DiffToolTest.java
@@ -20,8 +20,10 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
-import org.eclipse.jgit.internal.diffmergetool.CommandLineDiffTool;
+import org.eclipse.jgit.internal.diffmergetool.DiffTools;
+import org.eclipse.jgit.internal.diffmergetool.ExternalDiffTool;
import org.eclipse.jgit.lib.StoredConfig;
import org.junit.Before;
import org.junit.Test;
@@ -149,20 +151,38 @@ public class DiffToolTest extends ToolTestCase {
@Test
public void testToolHelp() throws Exception {
- CommandLineDiffTool[] defaultTools = CommandLineDiffTool.values();
List<String> expectedOutput = new ArrayList<>();
+
+ DiffTools diffTools = new DiffTools(db);
+ Map<String, ExternalDiffTool> predefinedTools = diffTools
+ .getPredefinedTools(true);
+ List<ExternalDiffTool> availableTools = new ArrayList<>();
+ List<ExternalDiffTool> notAvailableTools = new ArrayList<>();
+ for (ExternalDiffTool tool : predefinedTools.values()) {
+ if (tool.isAvailable()) {
+ availableTools.add(tool);
+ } else {
+ notAvailableTools.add(tool);
+ }
+ }
+
expectedOutput.add(
"'git difftool --tool=<tool>' may be set to one of the following:");
- for (CommandLineDiffTool defaultTool : defaultTools) {
- String toolName = defaultTool.name();
+ for (ExternalDiffTool tool : availableTools) {
+ String toolName = tool.getName();
expectedOutput.add(toolName);
}
String customToolHelpLine = TOOL_NAME + "." + CONFIG_KEY_CMD + " "
+ getEchoCommand();
expectedOutput.add("user-defined:");
expectedOutput.add(customToolHelpLine);
+ expectedOutput.add(
+ "The following tools are valid, but not currently available:");
+ for (ExternalDiffTool tool : notAvailableTools) {
+ String toolName = tool.getName();
+ expectedOutput.add(toolName);
+ }
String[] userDefinedToolsHelp = {
- "The following tools are valid, but not currently available:",
"Some of the tools listed above only work in a windowed",
"environment. If run in a terminal-only session, they will fail.",
};
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/MergeToolTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/MergeToolTest.java
index 2e50f09081..e9d559e70e 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/MergeToolTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/MergeToolTest.java
@@ -19,8 +19,10 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Map;
-import org.eclipse.jgit.internal.diffmergetool.CommandLineMergeTool;
+import org.eclipse.jgit.internal.diffmergetool.ExternalMergeTool;
+import org.eclipse.jgit.internal.diffmergetool.MergeTools;
import org.eclipse.jgit.lib.StoredConfig;
import org.junit.Before;
import org.junit.Test;
@@ -157,20 +159,38 @@ public class MergeToolTest extends ToolTestCase {
@Test
public void testToolHelp() throws Exception {
- CommandLineMergeTool[] defaultTools = CommandLineMergeTool.values();
List<String> expectedOutput = new ArrayList<>();
+
+ MergeTools diffTools = new MergeTools(db);
+ Map<String, ExternalMergeTool> predefinedTools = diffTools
+ .getPredefinedTools(true);
+ List<ExternalMergeTool> availableTools = new ArrayList<>();
+ List<ExternalMergeTool> notAvailableTools = new ArrayList<>();
+ for (ExternalMergeTool tool : predefinedTools.values()) {
+ if (tool.isAvailable()) {
+ availableTools.add(tool);
+ } else {
+ notAvailableTools.add(tool);
+ }
+ }
+
expectedOutput.add(
"'git mergetool --tool=<tool>' may be set to one of the following:");
- for (CommandLineMergeTool defaultTool : defaultTools) {
- String toolName = defaultTool.name();
+ for (ExternalMergeTool tool : availableTools) {
+ String toolName = tool.getName();
expectedOutput.add(toolName);
}
String customToolHelpLine = TOOL_NAME + "." + CONFIG_KEY_CMD + " "
+ getEchoCommand();
expectedOutput.add("user-defined:");
expectedOutput.add(customToolHelpLine);
+ expectedOutput.add(
+ "The following tools are valid, but not currently available:");
+ for (ExternalMergeTool tool : notAvailableTools) {
+ String toolName = tool.getName();
+ expectedOutput.add(toolName);
+ }
String[] userDefinedToolsHelp = {
- "The following tools are valid, but not currently available:",
"Some of the tools listed above only work in a windowed",
"environment. If run in a terminal-only session, they will fail.", };
expectedOutput.addAll(Arrays.asList(userDefinedToolsHelp));
n>"com.jcraft.jsch" version="0.1.55.v20190404-1902"/> <unit id="com.jcraft.jsch.source" version="0.1.55.v20190404-1902"/> <unit id="com.jcraft.jzlib" version="1.1.1.v201205102305"/> <unit id="com.jcraft.jzlib.source" version="1.1.1.v201205102305"/> <unit id="javaewah" version="1.1.7.v20200107-0831"/> <unit id="javaewah.source" version="1.1.7.v20200107-0831"/> <unit id="javax.servlet" version="3.1.0.v201410161800"/> <unit id="javax.servlet.source" version="3.1.0.v201410161800"/> <unit id="net.bytebuddy.byte-buddy" version="1.9.0.v20181107-1410"/> <unit id="net.bytebuddy.byte-buddy-agent" version="1.9.0.v20181106-1534"/> <unit id="net.bytebuddy.byte-buddy-agent.source" version="1.9.0.v20181106-1534"/> <unit id="net.bytebuddy.byte-buddy.source" version="1.9.0.v20181107-1410"/> <unit id="net.i2p.crypto.eddsa" version="0.3.0.v20181102-1323"/> <unit id="net.i2p.crypto.eddsa.source" version="0.3.0.v20181102-1323"/> <unit id="org.apache.ant" version="1.10.8.v20200515-1239"/> <unit id="org.apache.ant.source" version="1.10.8.v20200515-1239"/> <unit id="org.apache.commons.codec" version="1.13.0.v20200108-0001"/> <unit id="org.apache.commons.codec.source" version="1.13.0.v20200108-0001"/> <unit id="org.apache.commons.compress" version="1.19.0.v20200106-2343"/> <unit id="org.apache.commons.compress.source" version="1.19.0.v20200106-2343"/> <unit id="org.apache.commons.logging" version="1.2.0.v20180409-1502"/> <unit id="org.apache.commons.logging.source" version="1.2.0.v20180409-1502"/> <unit id="org.apache.httpcomponents.httpclient" version="4.5.10.v20200114-1512"/> <unit id="org.apache.httpcomponents.httpclient.source" version="4.5.10.v20200114-1512"/> <unit id="org.apache.httpcomponents.httpcore" version="4.4.12.v20200108-1212"/> <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.12.v20200108-1212"/> <unit id="org.apache.log4j" version="1.2.15.v201012070815"/> <unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/> <unit id="org.apache.sshd.osgi" version="2.4.0.v20200318-1614"/> <unit id="org.apache.sshd.osgi.source" version="2.4.0.v20200318-1614"/> <unit id="org.apache.sshd.sftp" version="2.4.0.v20200319-1547"/> <unit id="org.apache.sshd.sftp.source" version="2.4.0.v20200319-1547"/> <unit id="org.assertj" version="3.14.0.v20200120-1926"/> <unit id="org.assertj.source" version="3.14.0.v20200120-1926"/> <unit id="org.bouncycastle.bcpg" version="1.65.0.v20200527-1955"/> <unit id="org.bouncycastle.bcpg.source" version="1.65.0.v20200527-1955"/> <unit id="org.bouncycastle.bcpkix" version="1.65.0.v20200527-1955"/> <unit id="org.bouncycastle.bcpkix.source" version="1.65.0.v20200527-1955"/> <unit id="org.bouncycastle.bcprov" version="1.65.1.v20200529-1514"/> <unit id="org.bouncycastle.bcprov.source" version="1.65.1.v20200529-1514"/> <unit id="org.hamcrest" version="1.1.0.v20090501071000"/> <unit id="org.hamcrest.core" version="1.3.0.v20180420-1519"/> <unit id="org.hamcrest.core.source" version="1.3.0.v20180420-1519"/> <unit id="org.hamcrest.library" version="1.3.0.v20180524-2246"/> <unit id="org.hamcrest.library.source" version="1.3.0.v20180524-2246"/> <unit id="org.junit" version="4.13.0.v20200204-1500"/> <unit id="org.junit.source" version="4.13.0.v20200204-1500"/> <unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/> <unit id="org.kohsuke.args4j.source" version="2.33.0.v20160323-2218"/> <unit id="org.mockito" version="2.23.0.v20200310-1642"/> <unit id="org.mockito.source" version="2.23.0.v20200310-1642"/> <unit id="org.objenesis" version="2.6.0.v20180420-1519"/> <unit id="org.objenesis.source" version="2.6.0.v20180420-1519"/> <unit id="org.slf4j.api" version="1.7.2.v20121108-1250"/> <unit id="org.slf4j.api.source" version="1.7.2.v20121108-1250"/> <unit id="org.slf4j.impl.log4j12" version="1.7.2.v20131105-2200"/> <unit id="org.slf4j.impl.log4j12.source" version="1.7.2.v20131105-2200"/> <unit id="org.tukaani.xz" version="1.8.0.v20180207-1613"/> <unit id="org.tukaani.xz.source" version="1.8.0.v20180207-1613"/> <repository location="https://download.eclipse.org/tools/orbit/downloads/drops/R20200529191137/repository"/> </location> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <unit id="org.eclipse.osgi" version="0.0.0"/> <repository location="https://download.eclipse.org/releases/2019-12/201912181000/"/> </location> </locations> </target>