diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/IdeasyCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/IdeasyCommandlet.java index de46ad5a91..a762cd2c2b 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/IdeasyCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/IdeasyCommandlet.java @@ -8,6 +8,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -490,13 +491,13 @@ private void configureGitBashProfile(Path settingsPath, String bashPath) throws ObjectNode gitBashProfile = mapper.createObjectNode(); String newGuid = "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}"; String iconPath = getGitBashIconPath(bashPath); - String startingDirectory = this.context.getIdeRoot().toString(); + Path startingDirectory = Objects.requireNonNullElse(this.context.getIdeRoot(), this.context.getUserHome()); gitBashProfile.put("guid", newGuid); gitBashProfile.put("name", "Git Bash"); gitBashProfile.put("commandline", bashPath); gitBashProfile.put("icon", iconPath); - gitBashProfile.put("startingDirectory", startingDirectory); + gitBashProfile.put("startingDirectory", startingDirectory.toString()); ((ArrayNode) profilesList).add(gitBashProfile); diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/IdeasyCommandletTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/IdeasyCommandletTest.java index ef98a97de7..945e7fc192 100644 --- a/cli/src/test/java/com/devonfw/tools/ide/tool/IdeasyCommandletTest.java +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/IdeasyCommandletTest.java @@ -114,13 +114,22 @@ void testInstallIdeasy(String os) { + addedRcLines); } - /** Test of {@link IdeasyCommandlet#configureWindowsTerminalGitBash()}. */ - @Test - void testConfigureWindowsTerminalGitBash() { + /** + * Test of {@link IdeasyCommandlet#configureWindowsTerminalGitBash()}, also when {@code IDE_ROOT} is not yet set, as is the case during MSI installation. + * + * @param ideRootSet whether {@code IDE_ROOT} is set on the context. + */ + @ParameterizedTest + @ValueSource(booleans = { true, false }) + void testConfigureWindowsTerminalGitBash(boolean ideRootSet) { // arrange SystemInfo systemInfo = SystemInfoMock.of("windows"); IdeTestContext context = newContext("install"); + context.setSystemInfo(systemInfo); + if (!ideRootSet) { + context.setIdeRoot(null); + } IdeasyCommandlet ideasy = new IdeasyCommandlet(context); // act