mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-03 13:19:10 +01:00
add new MergeStrategies
This commit is contained in:
@@ -6,6 +6,8 @@ import sonia.scm.repository.spi.MergeCommand;
|
||||
import sonia.scm.repository.spi.MergeCommandRequest;
|
||||
import sonia.scm.repository.util.AuthorUtil;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Use this {@link MergeCommandBuilder} to merge two branches of a repository ({@link #executeMerge()}) or to check if
|
||||
* the branches could be merged without conflicts ({@link #dryRun()}). To do so, you have to specify the name of
|
||||
@@ -64,6 +66,10 @@ public class MergeCommandBuilder {
|
||||
return mergeCommand.isSupported(strategy);
|
||||
}
|
||||
|
||||
public Set<MergeStrategy> getSupportedMergeStrategies() {
|
||||
return mergeCommand.getSupportedMergeStrategies();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to set the branch that should be merged into the target branch.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package sonia.scm.repository.api;
|
||||
|
||||
public enum MergeStrategy {
|
||||
SQUASH
|
||||
SQUASH,
|
||||
MERGE_COMMIT,
|
||||
FAST_FORWARD_IF_POSSIBLE
|
||||
}
|
||||
|
||||
@@ -4,10 +4,14 @@ import sonia.scm.repository.api.MergeCommandResult;
|
||||
import sonia.scm.repository.api.MergeDryRunCommandResult;
|
||||
import sonia.scm.repository.api.MergeStrategy;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface MergeCommand {
|
||||
MergeCommandResult merge(MergeCommandRequest request);
|
||||
|
||||
MergeDryRunCommandResult dryRun(MergeCommandRequest request);
|
||||
|
||||
boolean isSupported(MergeStrategy strategy);
|
||||
|
||||
Set<MergeStrategy> getSupportedMergeStrategies();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,11 @@ public class GitMergeCommand extends AbstractGitCommand implements MergeCommand
|
||||
|
||||
private final GitWorkdirFactory workdirFactory;
|
||||
|
||||
private static final Set<MergeStrategy> STRATEGIES = ImmutableSet.of(MergeStrategy.SQUASH);
|
||||
private static final Set<MergeStrategy> STRATEGIES = ImmutableSet.of(
|
||||
MergeStrategy.SQUASH,
|
||||
MergeStrategy.MERGE_COMMIT,
|
||||
MergeStrategy.FAST_FORWARD_IF_POSSIBLE
|
||||
);
|
||||
|
||||
GitMergeCommand(GitContext context, sonia.scm.repository.Repository repository, GitWorkdirFactory workdirFactory) {
|
||||
super(context, repository);
|
||||
@@ -64,6 +68,11 @@ public class GitMergeCommand extends AbstractGitCommand implements MergeCommand
|
||||
return STRATEGIES.contains(strategy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<MergeStrategy> getSupportedMergeStrategies() {
|
||||
return STRATEGIES;
|
||||
}
|
||||
|
||||
private class MergeWorker extends GitCloneWorker<MergeCommandResult> {
|
||||
|
||||
private final String target;
|
||||
|
||||
Reference in New Issue
Block a user