Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1008: improve upgrade settings #1146

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
68623eb
#999: More flexible IDELogEntry comparison
leonrohne27 Mar 13, 2025
ee0472a
Merge branch 'main' into fix/999-make-idelogentry-comparing-more-flex…
leonrohne27 Mar 13, 2025
9dcfdc1
#1130: Improve behaviour on ambigous xpath match
leonrohne27 Mar 17, 2025
f832220
fix
KianRolf Mar 17, 2025
49ef8ef
Update IdeTestLoggerAssertion.java
KianRolf Mar 17, 2025
0dcb661
Update IdeTestLoggerAssertion.java
leonrohne27 Mar 17, 2025
e37e0b4
Merge branch 'main' into fix/1130-improve-behaviour-on-ambigous-xpath…
leonrohne27 Mar 17, 2025
c359522
#
leonrohne27 Mar 18, 2025
2c30607
Merge branch 'main' into fix/1130-improve-behaviour-on-ambigous-xpath…
leonrohne27 Mar 18, 2025
e8a9fc0
#
leonrohne27 Mar 18, 2025
be644c6
Merge branch 'fix/1130-improve-behaviour-on-ambigous-xpath-match' of …
leonrohne27 Mar 18, 2025
255542a
#1008: improve upgrade-settings commandlet
leonrohne27 Mar 19, 2025
9610ea9
#fixed branch issues
leonrohne27 Mar 19, 2025
2dfc249
Merge branch 'main' into fix/1008-improve-upgrade-settings
leonrohne27 Mar 20, 2025
6345aa9
Merge branch 'main' into fix/1008-improve-upgrade-settings
leonrohne27 Mar 21, 2025
ad54840
Update cli/src/main/java/com/devonfw/tools/ide/commandlet/UpgradeSett…
leonrohne27 Mar 21, 2025
f890489
Update cli/src/main/java/com/devonfw/tools/ide/commandlet/UpgradeSett…
leonrohne27 Mar 21, 2025
e17e2b5
Update cli/src/main/java/com/devonfw/tools/ide/commandlet/UpgradeSett…
leonrohne27 Mar 21, 2025
2c26a35
#1008: implemented suggested changes
leonrohne27 Mar 25, 2025
e6105ad
Merge branch 'main' into fix/1008-improve-upgrade-settings
leonrohne27 Mar 25, 2025
3373079
Merge branch 'main' into fix/1008-improve-upgrade-settings
jan-vcapgemini Mar 26, 2025
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
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.devonfw.tools.ide.commandlet;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.nio.file.StandardOpenOption;
import java.util.List;
import java.util.function.Function;

import com.devonfw.tools.ide.context.IdeContext;
Expand Down Expand Up @@ -139,6 +142,7 @@ private void updateProperties(EnvironmentVariablesPropertiesFile environmentVari
}
updatePropertiesLegacyEdition(environmentVariables, "INTELLIJ_EDITION_TYPE", "INTELLIJ_EDITION", this::mapLegacyIntellijEdition);
updatePropertiesLegacyEdition(environmentVariables, "ECLIPSE_EDITION_TYPE", "ECLIPSE_EDITION", this::mapLegacyEclipseEdition);
cleanupLegacyProperties();
environmentVariables.save();
this.context.getFileAccess().backup(environmentVariables.getLegacyPropertiesFilePath());
}
Expand Down Expand Up @@ -181,4 +185,51 @@ private static void updatePropertiesLegacyEdition(EnvironmentVariablesProperties
environmentVariables.remove(legacyEditionVariable);
}
}

private void cleanupLegacyProperties() {
this.context.info("Cleaning up legacy properties...");

Path settingsPath = context.getSettingsPath();
Path repositoriesPath = settingsPath.resolve(IdeContext.FOLDER_REPOSITORIES);

FileAccess fileAccess = this.context.getFileAccess();
if (fileAccess.isExpectedFolder(repositoriesPath)) {
fileAccess.listChildrenMapped(repositoriesPath, child -> {
try {
updateRepositoryPropertiesFile(child);
} catch (IOException e) {
throw new RuntimeException(e);
}
return null;
});
}
}

private void updateRepositoryPropertiesFile(Path filePath) throws IOException {
List<String> lines = Files.readAllLines(filePath);
boolean updated = false;

for (int i = 0; i < lines.size(); i++) {
String line = lines.get(i).trim();
if (line.startsWith("git.url=") || line.startsWith("git-url")) {
String gitUrl = line.substring(line.indexOf("=") + 1).trim();
lines.set(i, "git_url=" + gitUrl);
updated = true;
continue;
}
if (line.startsWith("eclipse=import")) {
lines.set(i, "import=eclipse");
updated = true;
}
}
if (updated) {
try {
Files.write(filePath, lines, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);
this.context.success("Successfully updated repository configuration file {}", filePath);
} catch (IOException e) {
this.context.error("Failed to write updated repository configuration file {}", filePath);
throw e;
}
}
}
}