mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 17:56:17 +01:00
Resolve plugin installation conflict were the same plugin was tried to be installed multiple times for one single action. (#2138)
The pending queue is updated after all the plugins to be installed are collected, and then we already may have duplicate entries. Because of this we check right on the collecting step if the plugin was already added during this single action.
This commit is contained in:
2
gradle/changelog/plugin_installation_conflict.yaml
Normal file
2
gradle/changelog/plugin_installation_conflict.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- type: fixed
|
||||||
|
description: Plugin installation conflict ([#2138](https://github.com/scm-manager/scm-manager/pull/2138))
|
||||||
@@ -357,7 +357,13 @@ public class DefaultPluginManager implements PluginManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins.add(plugin);
|
if (pluginWasNotAddedYet(plugins, plugin)) {
|
||||||
|
plugins.add(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean pluginWasNotAddedYet(List<AvailablePlugin> plugins, AvailablePlugin plugin) {
|
||||||
|
return plugins.stream().noneMatch(p -> p.getDescriptor().getInformation().getName().equals(plugin.getDescriptor().getInformation().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isInstalledOrPending(String name) {
|
private boolean isInstalledOrPending(String name) {
|
||||||
|
|||||||
@@ -242,6 +242,24 @@ class DefaultPluginManagerTest {
|
|||||||
verify(installer).install(context, review);
|
verify(installer).install(context, review);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldInstallMultipleSameDependingPluginsOnlyOnce() {
|
||||||
|
AvailablePlugin review = createAvailable("scm-review-plugin");
|
||||||
|
AvailablePlugin ci = createAvailable("scm-ci-plugin", "1.1.0");
|
||||||
|
InstalledPlugin oldCi = createInstalled("scm-ci-plugin", "1.0.0");
|
||||||
|
when(review.getDescriptor().getDependencies()).thenReturn(ImmutableSet.of("scm-mail-plugin", "scm-ci-plugin"));
|
||||||
|
AvailablePlugin mail = createAvailable("scm-mail-plugin");
|
||||||
|
when(mail.getDescriptor().getOptionalDependencies()).thenReturn(ImmutableSet.of("scm-ci-plugin"));
|
||||||
|
when(center.getAvailablePlugins()).thenReturn(ImmutableSet.of(review, mail, ci));
|
||||||
|
when(loader.getInstalledPlugins()).thenReturn(ImmutableSet.of(oldCi));
|
||||||
|
|
||||||
|
manager.install("scm-review-plugin", false);
|
||||||
|
|
||||||
|
verify(installer).install(context, mail);
|
||||||
|
verify(installer).install(context, review);
|
||||||
|
verify(installer, times(1)).install(context, ci);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldNotInstallAlreadyInstalledDependenciesWhenUpToDate() {
|
void shouldNotInstallAlreadyInstalledDependenciesWhenUpToDate() {
|
||||||
AvailablePlugin review = createAvailable("scm-review-plugin");
|
AvailablePlugin review = createAvailable("scm-review-plugin");
|
||||||
|
|||||||
Reference in New Issue
Block a user