mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 00:15:44 +01:00
Execute updates in order
This commit is contained in:
@@ -1,17 +1,29 @@
|
||||
package sonia.scm;
|
||||
|
||||
import sonia.scm.migration.UpdateStep;
|
||||
import sonia.scm.version.Version;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
public class UpdateEngine {
|
||||
|
||||
private final Set<UpdateStep> steps;
|
||||
private final List<UpdateStep> steps;
|
||||
|
||||
@Inject
|
||||
public UpdateEngine(Set<UpdateStep> steps) {
|
||||
this.steps = steps;
|
||||
this.steps = sortSteps(steps);
|
||||
}
|
||||
|
||||
private List<UpdateStep> sortSteps(Set<UpdateStep> steps) {
|
||||
Comparator<UpdateStep> compareByVersion = Comparator.comparing(step -> Version.parse(step.getTargetVersion()));
|
||||
return steps.stream()
|
||||
.sorted(compareByVersion.reversed())
|
||||
.collect(toList());
|
||||
}
|
||||
|
||||
public void update() {
|
||||
|
||||
Reference in New Issue
Block a user