Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE

Release with new features and bugfixes:

* https://github.com/devonfw/IDEasy/issues/1270[#1270]: IDEasy now loads global user settings if outside a project
* https://github.com/devonfw/IDEasy/issues/1552[#1552]: Add Commandlet to fix TLS issue
* https://github.com/devonfw/IDEasy/issues/1760[#1760]: Accept empty input for single option

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.devonfw.tools.ide.commandlet;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
Expand All @@ -8,7 +9,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.devonfw.tools.ide.cli.CliExitException;
import com.devonfw.tools.ide.context.AbstractIdeContext;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.environment.EnvironmentVariablesType;
Expand Down Expand Up @@ -65,9 +65,6 @@ public boolean isProcessableOutput() {

@Override
protected void doRun() {
if (this.context.getIdeHome() == null) {
throw new CliExitException();
}

boolean winCmd = false;
WindowsPathSyntax pathSyntax = null;
Expand All @@ -84,9 +81,12 @@ protected void doRun() {
List<VariableLine> variables = this.context.getVariables().collectVariables();
Map<String, VariableLine> variableMap = variables.stream().collect(Collectors.toMap(VariableLine::getName, v -> v));

EnvironmentVariableCollectorContext environmentVariableCollectorContext = new EnvironmentVariableCollectorContext(variableMap,
new VariableSource(EnvironmentVariablesType.TOOL, this.context.getSoftwarePath()), pathSyntax);
setEnvironmentVariablesInLocalTools(environmentVariableCollectorContext);
Path softwarePath = this.context.getSoftwarePath();
if (softwarePath != null) {
EnvironmentVariableCollectorContext environmentVariableCollectorContext = new EnvironmentVariableCollectorContext(variableMap,
new VariableSource(EnvironmentVariablesType.TOOL, softwarePath), pathSyntax);
setEnvironmentVariablesInLocalTools(environmentVariableCollectorContext);
}

printLines(variableMap, winCmd);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,9 @@ public Path getUserHome() {
protected void setUserHome(Path userHome) {

this.userHome = userHome;
this.userHomeIde = userHome.resolve(FOLDER_DOT_IDE);
this.downloadPath = userHome.resolve("Downloads/ide");
this.variables = null;
resetPrivacyMap();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.devonfw.tools.ide.commandlet;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import com.devonfw.tools.ide.context.AbstractIdeContextTest;
import com.devonfw.tools.ide.context.IdeTestContext;
import com.devonfw.tools.ide.log.IdeLogEntry;

/**
* Test of {@link EnvironmentCommandlet} for global configuration.
*/
class EnvironmentCommandletGlobalTest extends AbstractIdeContextTest {

@Test
void testRunOutsideProject(@TempDir Path tempDir) throws IOException {

// arrange
Path userHome = tempDir.resolve("user");
Path userHomeIde = userHome.resolve(".ide");
Files.createDirectories(userHomeIde);
Files.writeString(userHomeIde.resolve("ide.properties"), "export FOO=bar\n");

IdeTestContext context = new IdeTestContext(tempDir.resolve("cwd"), null);
context.setUserHome(userHome);

EnvironmentCommandlet env = context.getCommandletManager().getCommandlet(EnvironmentCommandlet.class);

// act
env.run();

// assert
assertThat(context).log().hasEntries( //
IdeLogEntry.ofProcessable("export FOO=\"bar\"") //
);
}
}
Loading