mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-12-24 01:09:48 +01:00
Use dedicated exception for unsupported merge strategies
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package sonia.scm.repository.api;
|
||||
|
||||
import sonia.scm.BadRequestException;
|
||||
import sonia.scm.repository.Repository;
|
||||
|
||||
import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
||||
|
||||
@SuppressWarnings("squid:MaximumInheritanceDepth") // exceptions have a deep inheritance depth themselves; therefore we accept this here
|
||||
public class MergeStrategyNotSupportedException extends BadRequestException {
|
||||
|
||||
private static final long serialVersionUID = 256498734456613496L;
|
||||
|
||||
private static final String CODE = "6eRhF9gU41";
|
||||
|
||||
public MergeStrategyNotSupportedException(Repository repository, MergeStrategy strategy) {
|
||||
super(entity(repository).build(), createMessage(strategy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCode() {
|
||||
return CODE;
|
||||
}
|
||||
|
||||
private static String createMessage(MergeStrategy strategy) {
|
||||
return "merge strategy " + strategy + " is not supported by this repository";
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import sonia.scm.repository.InternalRepositoryException;
|
||||
import sonia.scm.repository.api.MergeCommandResult;
|
||||
import sonia.scm.repository.api.MergeDryRunCommandResult;
|
||||
import sonia.scm.repository.api.MergeStrategy;
|
||||
import sonia.scm.repository.api.MergeStrategyNotSupportedException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
@@ -46,7 +47,7 @@ public class GitMergeCommand extends AbstractGitCommand implements MergeCommand
|
||||
return inClone(clone -> new GitMergeCommit(clone, request, context, repository), workdirFactory, request.getTargetBranch());
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("unknown merge strategy: " + request.getMergeStrategy());
|
||||
throw new MergeStrategyNotSupportedException(repository, request.getMergeStrategy());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -183,6 +183,10 @@
|
||||
"65RdZ5atX1": {
|
||||
"displayName": "Fehler beim Löschen von Plugin-Dateien",
|
||||
"description": "Einige Dateien für die Plugin-Deinstallation konnten nicht gelöscht werden. Dieses kann zu Inkonsistenzen führen, so dass der SCM-Manager nicht mehr korrekt starten kann. Bitte prüfen Sie die Logs und bereinigen Sie das Plugin-Verzeichnis des SCM-Managers manuell. Um die Installation eines Plugins abzubrechen, löschen Sie die zugehörige smp Datei aus dem Plugin-Verzeichnis. Um ein Entfernen eines Plugins zu verhindern, entfernen Sie die Datei namens 'uninstall' aus dem entsprechenden Verzeichnis des Plugins."
|
||||
},
|
||||
"6eRhF9gU41": {
|
||||
"displayName": "Nicht unterstützte Merge-Strategie",
|
||||
"description": "Die gewählte Merge-Strategie wird von dem Repository nicht unterstützt."
|
||||
}
|
||||
},
|
||||
"namespaceStrategies": {
|
||||
|
||||
@@ -183,6 +183,10 @@
|
||||
"65RdZ5atX1": {
|
||||
"displayName": "Error removing plugin files",
|
||||
"description": "Some files to cancel the plugin (un)installation could not be deleted. This can lead to inconsistencies so that the SCM-Manager cannot restart properly. Please check the logs and clean up the plugin folder manually. To cancel the installation of a plugin, remove the corresponding smp file. To cancel the uninstallation, remove the file named 'uninstall' inside the directory for this plugin."
|
||||
},
|
||||
"6eRhF9gU41": {
|
||||
"displayName": "Merge strategy not supported",
|
||||
"description": "The selected merge strategy is not supported by the repository."
|
||||
}
|
||||
},
|
||||
"namespaceStrategies": {
|
||||
|
||||
Reference in New Issue
Block a user