Skip to content

Commit d9c6911

Browse files
committed
#1594: Code cleanup and bug fixes
1 parent 8c48725 commit d9c6911

7 files changed

Lines changed: 18 additions & 39 deletions

File tree

cli/src/main/java/com/devonfw/tools/ide/commandlet/ReleaseCommandlet.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.nio.file.Path;
55
import java.util.ArrayList;
66
import java.util.List;
7-
import java.util.concurrent.locks.ReentrantLock;
87

98
import org.slf4j.Logger;
109
import org.slf4j.LoggerFactory;
@@ -51,13 +50,13 @@ protected void doRun() {
5150
GitContext git = this.context.getGitContext();
5251

5352
if (git.hasUntrackedFiles(projectPath)) {
54-
throw new CliException("Your local git repository has uncommitted changes. Please use 'git stash' and rerun on a clean repository.");
53+
throw new CliException("Your local git repository has uncommitted changes. Please use 'git stash' and rerun on clean repo.");
5554
}
5655
if (warnIfFork(git, projectPath)) {
5756
confirmWarning("You seem to work on a fork. Releases should be done on the original repository!\nWe strongly recommend to abort and rerun on original repository.");
5857
}
5958
if (!this.context.isForceMode() && !isTopLevelProject(projectPath)) {
60-
throw new CliException("Release has to be performed from the top-level project or using the force option (-f).");
59+
throw new CliException("Release has to be performed from the top-level project or using force option.");
6160
}
6261

6362
String currentVersion = getProjectVersion(projectPath);
@@ -76,15 +75,18 @@ protected void doRun() {
7675
}
7776

7877
setProjectVersion(projectPath, releaseVersion);
79-
git.commit(projectPath, "#release: set release version " + releaseVersion);
80-
git.tag(projectPath, releaseVersion);
78+
git.commit(projectPath, "set release version to " + releaseVersion);
79+
git.tag(projectPath, "release/" + releaseVersion, "tagged version " + releaseVersion);
8180

8281
buildAndDeploy();
8382

8483
setProjectVersion(projectPath, nextVersion);
85-
git.commit(projectPath, "#release: set next snapshot version " + nextVersion);
84+
git.commit(projectPath, "set next version to " + nextVersion);
85+
LOG.info("Local commits and tag need to be pushed now.\nYou now have the chance to review these changes manually before they are pushed.");
86+
this.context.askToContinue("Do you want to continue?");
8687
git.push(projectPath);
8788

89+
LOG.info("Successfully released version {}.", releaseVersion);
8890
}
8991

9092
private boolean warnIfFork(GitContext git, Path projectPath) {
@@ -158,9 +160,8 @@ private void buildAndDeploy() {
158160
return;
159161
}
160162
LOG.error("Release build failed!");
161-
if (!this.context.question("Do you want to retry the release build?")) {
162-
throw new CliException("Release build failed and was aborted! The release commit and tag were already created locally - "
163-
+ "undo them via 'git reset --hard HEAD~1' and 'git tag -d <version>' before retrying.");
163+
if (!this.context.question("Do you want to retry the build (e.g. in case of a temporary network error)?")) {
164+
throw new CliException("Release build failed and process aborted!\nYou should reset your local commits via 'git reset HEAD^'.");
164165
}
165166
}
166167
}

cli/src/main/java/com/devonfw/tools/ide/git/GitContext.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,6 @@ default void reset(Path repository, String branch) {
213213
*/
214214
String retrieveGitUrl(Path repository);
215215

216-
/**
217-
* @param repository the {@link Path} to the git repository.
218-
* @return the {@link List} of git tags of the given repository.
219-
*/
220-
List<String> retrieveGitTags(Path repository);
221-
222216
/**
223217
* @param repository the {@link Path} to the git repository.
224218
* @return the {@link List} of configured git remotes (output of {@code git remote -v}).
@@ -272,8 +266,9 @@ default void reset(Path repository, String branch) {
272266
*
273267
* @param repository the {@link Path} to the git repository.
274268
* @param tagName the name of the tag to create (e.g. "release/1.5.0").
269+
* @param message the annotation message of the tag.
275270
*/
276-
void tag(Path repository, String tagName);
271+
void tag(Path repository, String tagName, String message);
277272

278273
/**
279274
* Pushes the local commits and tags of the given repository to the remote repository.

cli/src/main/java/com/devonfw/tools/ide/git/GitContextImpl.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,6 @@ public String retrieveGitUrl(Path repository) {
320320
return runGitCommandAndGetSingleOutput("Failed to retrieve git URL for repository", repository, "config", "--get", "remote.origin.url");
321321
}
322322

323-
@Override
324-
public List<String> retrieveGitTags(Path repository) {
325-
326-
return runGitCommand(repository, ProcessMode.DEFAULT_CAPTURE, "--no-pager", "tag", "--list").getOut();
327-
}
328-
329323
@Override
330324
public List<String> retrieveGitRemotes(Path repository) {
331325

@@ -546,9 +540,9 @@ public void commit(Path repository, String message) {
546540
}
547541

548542
@Override
549-
public void tag(Path repository, String tagName) {
543+
public void tag(Path repository, String tagName, String message) {
550544

551-
runGitCommand(repository, "tag", "-a", tagName, "-m", tagName);
545+
runGitCommand(repository, "tag", "-a", tagName, "-m", message);
552546
}
553547

554548
@Override

cli/src/main/resources/nls/Help.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ cmd.python.detail=Python is an object-oriented programming language, comparable
112112
cmd.quarkus=Tool commandlet for Quarkus (framework for cloud-native apps).
113113
cmd.quarkus.detail=Quarkus is a Kubernetes-native Java framework for building cloud-native applications. Detailed documentation can be found at https://quarkus.io/
114114
cmd.release=Performs a release of the project in your current working directory.
115-
cmd.release.detail=The `release` commandlet automates a release of the project in your current working directory. It ensures there are no uncommitted changes, warns if you work on a fork, determines the current version of your project and derives the release version and the next development (SNAPSHOT) version for you to confirm. It then sets the release version, commits and tags it via git (as `release/«version»`), builds and deploys the project, sets the next development version, commits, and (after your confirmation) pushes the changes and the tag. Build and deploy options can be configured per build-system via the variable `<TOOL>_RELEASE_OPTS` (e.g. `MVN_RELEASE_OPTS`). You may also supply additional arguments as `ide release «args»` that will be passed to the detected build command.
115+
cmd.release.detail=The `release` commandlet automates a release of the project in your current working directory. It ensures there are no uncommitted changes, warns if you work on a fork, determines the current version of your project and derives the release version and the next development (SNAPSHOT) version for you to confirm. It then sets the release version, commits and tags it via git (as `release/«version»`), builds and deploys the project, sets the next development version, commits, and (after your confirmation) pushes the changes and the tag. Build and deploy options can be configured via the variable `MVN_RELEASE_OPTS` (default `clean deploy -Dchangelist= -Pdeploy`). You may also supply additional arguments as `ide release «args»` that will be passed to the maven build command.
116116
cmd.release.val.args=Additional arguments to pass to the build and deploy command.
117117
cmd.repository=Set up pre-configured git repositories using 'ide repository setup <repository>'
118118
cmd.repository.detail=Without further arguments this will set up all pre-configured git repositories.\nAlso, you can provide an explicit git repo as `<repository>` argument and IDEasy will automatically clone, build and set up your project based on the existing property file.\nRepositories are configured in 'settings/repository/<repository>.properties' and can therefore be shared with your project team for automatic or optional setup.

cli/src/main/resources/nls/Help_de.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ cmd.python.detail=Python ist eine objektorientierte Programmiersprache, vergleic
112112
cmd.quarkus=Werkzeug Kommando für Quarkus (Framework für Cloud-native Anwendungen).
113113
cmd.quarkus.detail=Quarkus ist ein Kubernetes-native Java-Framework zur Entwicklung von Cloud-native Anwendungen. Detaillierte Dokumentation ist zu finden unter https://quarkus.io/
114114
cmd.release=Führt ein Release des Projekts in Ihrem aktuellen Arbeitsverzeichnis durch.
115-
cmd.release.detail=Der `release`-Befehl automatisiert ein Release des Projekts in Ihrem aktuellen Arbeitsverzeichnis. Er stellt sicher, dass keine uncommitteten Änderungen vorliegen, warnt wenn Sie auf einem Fork arbeiten, ermittelt die aktuelle Version Ihres Projekts und leitet daraus die Release-Version sowie die nächste Entwicklungsversion (SNAPSHOT) zur Bestätigung ab. Anschließend setzt er die Release-Version, committet und taggt sie via git (als `release/«version»`), baut und veröffentlicht das Projekt, setzt die nächste Entwicklungsversion, committet und pusht nach Ihrer Bestätigung die Änderungen und den Tag. Build- und Deploy-Optionen können pro Build-System über die Variable `<TOOL>_RELEASE_OPTS` (z. B. `MVN_RELEASE_OPTS`) konfiguriert werden. Sie können auch zusätzliche Argumente wie `ide release «args»` angeben, die an den erkannten Build-Befehl weitergeleitet werden.
115+
cmd.release.detail=Der `release`-Befehl automatisiert ein Release des Projekts in Ihrem aktuellen Arbeitsverzeichnis. Er stellt sicher, dass keine uncommitteten Änderungen vorliegen, warnt wenn Sie auf einem Fork arbeiten, ermittelt die aktuelle Version Ihres Projekts und leitet daraus die Release-Version sowie die nächste Entwicklungsversion (SNAPSHOT) zur Bestätigung ab. Anschließend setzt er die Release-Version, committet und taggt sie via git (als `release/«version»`), baut und veröffentlicht das Projekt, setzt die nächste Entwicklungsversion, committet und pusht nach Ihrer Bestätigung die Änderungen und den Tag. Build- und Deploy-Optionen können über die Variable `MVN_RELEASE_OPTS` (Standard `clean deploy -Dchangelist= -Pdeploy`) konfiguriert werden. Sie können auch zusätzliche Argumente wie `ide release «args»` angeben, die an den Maven-Build-Befehl weitergeleitet werden.
116116
cmd.release.val.args=Zusätzliche Argumente, die an den Build- und Deploy-Befehl übergeben werden.
117117
cmd.repository=Richtet das vorkonfigurierte Git Repository ein mittels 'ide repository setup <repository>'.
118118
cmd.repository.detail=Dies wird alle vorkonfigurierten Repositories einrichten. Rufen Sie einfach 'ide repository setup <your_project_name>' auf, ersetzen Sie <your_project_name> durch den Namen Ihrer Projektkonfigurationsdatei, die sich in 'settings/repository/your_project_name' befindet und IDEasy wird Ihr Projekt basierend auf der vorhandenen Eigenschaftsdatei automatisch klonen, bauen und einrichten.\nWenn Sie den Projektnamen weglassen, werden alle im Repository-Verzeichnis gefundenen Projekte vorkonfiguriert.

cli/src/test/java/com/devonfw/tools/ide/git/GitContextImplMock.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public void commit(Path repository, String message) {
223223
}
224224

225225
@Override
226-
public void tag(Path repository, String tagName) {
226+
public void tag(Path repository, String tagName, String message) {
227227
LOG.debug("Mock tag: {}", tagName);
228228
}
229229

@@ -232,11 +232,6 @@ public void push(Path repository) {
232232
LOG.debug("Mock push");
233233
}
234234

235-
@Override
236-
public List<String> retrieveGitTags(Path repository) {
237-
return List.of();
238-
}
239-
240235
@Override
241236
public List<String> retrieveGitRemotes(Path repository) {
242237
return List.of();

cli/src/test/java/com/devonfw/tools/ide/git/GitContextMock.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ public String retrieveGitUrl(Path repository) {
6565
return MOCKED_URL_VALUE;
6666
}
6767

68-
@Override
69-
public java.util.List<String> retrieveGitTags(Path repository) {
70-
71-
return java.util.Collections.emptyList();
72-
}
73-
7468
@Override
7569
public java.util.List<String> retrieveGitRemotes(Path repository) {
7670

@@ -135,7 +129,7 @@ public void commit(Path repository, String message) {
135129
}
136130

137131
@Override
138-
public void tag(Path repository, String tagName) {
132+
public void tag(Path repository, String tagName, String message) {
139133

140134
}
141135

0 commit comments

Comments
 (0)