From 973e955ead1a9bf41efb3168baf5b68527e78023 Mon Sep 17 00:00:00 2001 From: Andre Bossert Date: Sun, 19 Jan 2020 20:56:28 +0100 Subject: 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 --- .../internal/diffmergetool/ExternalDiffToolTest.java | 13 ++----------- .../internal/diffmergetool/ExternalMergeToolTest.java | 17 ++++------------- 2 files changed, 6 insertions(+), 24 deletions(-) (limited to 'org.eclipse.jgit.test/tst/org/eclipse') diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/diffmergetool/ExternalDiffToolTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/diffmergetool/ExternalDiffToolTest.java index 4fd55c6cad..1b501c25b0 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/diffmergetool/ExternalDiffToolTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/diffmergetool/ExternalDiffToolTest.java @@ -97,7 +97,7 @@ public class ExternalDiffToolTest extends ExternalToolTestCase { @Test public void testAllTools() { DiffTools manager = new DiffTools(db); - Set actualToolNames = manager.getAvailableTools().keySet(); + Set actualToolNames = manager.getPredefinedTools(true).keySet(); Set expectedToolNames = new LinkedHashSet<>(); CommandLineDiffTool[] defaultTools = CommandLineDiffTool.values(); for (CommandLineDiffTool defaultTool : defaultTools) { @@ -152,15 +152,6 @@ public class ExternalDiffToolTest extends ExternalToolTestCase { actualToolNames); } - @Test - public void testNotAvailableTools() { - DiffTools manager = new DiffTools(db); - Set actualToolNames = manager.getNotAvailableTools().keySet(); - Set expectedToolNames = Collections.emptySet(); - assertEquals("Incorrect set of not available external diff tools", - expectedToolNames, actualToolNames); - } - @Test public void testCompare() throws ToolException { String toolName = "customTool"; @@ -239,7 +230,7 @@ public class ExternalDiffToolTest extends ExternalToolTestCase { DiffTools manager = new DiffTools(db); Map availableTools = manager - .getAvailableTools(); + .getPredefinedTools(true); ExternalDiffTool externalDiffTool = availableTools .get(overridenToolName); String actualDiffToolPath = externalDiffTool.getPath(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/diffmergetool/ExternalMergeToolTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/diffmergetool/ExternalMergeToolTest.java index 50576682eb..305f2b470e 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/diffmergetool/ExternalMergeToolTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/diffmergetool/ExternalMergeToolTest.java @@ -9,14 +9,14 @@ */ package org.eclipse.jgit.internal.diffmergetool; -import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_MERGETOOL_SECTION; -import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_MERGE_SECTION; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_CMD; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_GUITOOL; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_PATH; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_PROMPT; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_TOOL; import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_TRUST_EXIT_CODE; +import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_MERGETOOL_SECTION; +import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_MERGE_SECTION; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -95,7 +95,7 @@ public class ExternalMergeToolTest extends ExternalToolTestCase { @Test public void testAllTools() { MergeTools manager = new MergeTools(db); - Set actualToolNames = manager.getAvailableTools().keySet(); + Set actualToolNames = manager.getPredefinedTools(true).keySet(); Set expectedToolNames = new LinkedHashSet<>(); CommandLineMergeTool[] defaultTools = CommandLineMergeTool.values(); for (CommandLineMergeTool defaultTool : defaultTools) { @@ -150,15 +150,6 @@ public class ExternalMergeToolTest extends ExternalToolTestCase { actualToolNames); } - @Test - public void testNotAvailableTools() { - MergeTools manager = new MergeTools(db); - Set actualToolNames = manager.getNotAvailableTools().keySet(); - Set expectedToolNames = Collections.emptySet(); - assertEquals("Incorrect set of not available external merge tools", - expectedToolNames, actualToolNames); - } - @Test public void testCompare() throws ToolException { String toolName = "customTool"; @@ -236,7 +227,7 @@ public class ExternalMergeToolTest extends ExternalToolTestCase { MergeTools manager = new MergeTools(db); Map availableTools = manager - .getAvailableTools(); + .getPredefinedTools(true); ExternalMergeTool externalMergeTool = availableTools .get(overridenToolName); String actualMergeToolPath = externalMergeTool.getPath(); -- cgit v1.2.3