mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-18 03:01:05 +01:00
Introduce feature for incoming changes
This commit is contained in:
@@ -45,5 +45,10 @@ public enum Feature
|
||||
* The default branch of the repository is a combined branch of all
|
||||
* repository branches.
|
||||
*/
|
||||
COMBINED_DEFAULT_BRANCH
|
||||
COMBINED_DEFAULT_BRANCH,
|
||||
/**
|
||||
* The repository supports computation of incoming changes (either diff or list of changesets) of one branch
|
||||
* in respect to another target branch.
|
||||
*/
|
||||
INCOMING
|
||||
}
|
||||
|
||||
@@ -174,7 +174,8 @@ public final class DiffCommandBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the difference only for the given revision.
|
||||
* Show the difference only for the given revision or (using {@link #setAncestorChangeset(String)}) between this
|
||||
* and another revision.
|
||||
*
|
||||
*
|
||||
* @param revision revision for difference
|
||||
@@ -188,9 +189,9 @@ public final class DiffCommandBuilder
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Show the difference between the ancestor changeset and a revision.
|
||||
*
|
||||
* @param revision ancestor revision
|
||||
* Compute the incoming changes of the branch set with {@link #setRevision(String)} in respect to the changeset given
|
||||
* here. In other words: What changes would be new to the ancestor changeset given here when the branch would
|
||||
* be merged into it. Requires feature {@link sonia.scm.repository.Feature#INCOMING}!
|
||||
*
|
||||
* @return {@code this}
|
||||
*/
|
||||
|
||||
@@ -397,6 +397,13 @@ public final class LogCommandBuilder
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the incoming changes of the branch set with {@link #setBranch(String)} in respect to the changeset given
|
||||
* here. In other words: What changesets would be new to the ancestor changeset given here when the branch would
|
||||
* be merged into it. Requires feature {@link sonia.scm.repository.Feature#INCOMING}!
|
||||
*
|
||||
* @return {@code this}
|
||||
*/
|
||||
public LogCommandBuilder setAncestorChangeset(String ancestorChangeset) {
|
||||
request.setAncestorChangeset(ancestorChangeset);
|
||||
return this;
|
||||
|
||||
@@ -33,12 +33,13 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import sonia.scm.repository.Feature;
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.api.Command;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -52,7 +53,7 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
|
||||
|
||||
/** Field description */
|
||||
//J-
|
||||
public static final Set<Command> COMMANDS = ImmutableSet.of(
|
||||
public static final Set<Command> COMMANDS = EnumSet.of(
|
||||
Command.BLAME,
|
||||
Command.BROWSE,
|
||||
Command.CAT,
|
||||
@@ -66,6 +67,7 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
|
||||
Command.PULL,
|
||||
Command.MERGE
|
||||
);
|
||||
public static final Set<Feature> FEATURES = EnumSet.of(Feature.INCOMING);
|
||||
//J+
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
@@ -246,6 +248,10 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
|
||||
return new GitMergeCommand(context, repository, handler.getWorkdirFactory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Feature> getSupportedFeatures() {
|
||||
return FEATURES;
|
||||
}
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
|
||||
@@ -196,11 +196,15 @@ public class RepositoryResource {
|
||||
return permissionRootResource.get();
|
||||
}
|
||||
|
||||
@Path("modifications/")
|
||||
public ModificationsRootResource modifications() {return modificationsRootResource.get(); }
|
||||
@Path("modifications/")
|
||||
public ModificationsRootResource modifications() {
|
||||
return modificationsRootResource.get();
|
||||
}
|
||||
|
||||
@Path("incoming/")
|
||||
public IncomingRootResource incoming() {return incomingRootResource.get(); }
|
||||
@Path("incoming/")
|
||||
public IncomingRootResource incoming() {
|
||||
return incomingRootResource.get();
|
||||
}
|
||||
|
||||
private Optional<Response> handleNotArchived(Throwable throwable) {
|
||||
if (throwable instanceof RepositoryIsNotArchivedException) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import de.otto.edison.hal.Links;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import sonia.scm.repository.Feature;
|
||||
import sonia.scm.repository.HealthCheckFailure;
|
||||
import sonia.scm.repository.Repository;
|
||||
import sonia.scm.repository.RepositoryPermissions;
|
||||
@@ -55,11 +56,13 @@ public abstract class RepositoryToRepositoryDtoMapper extends BaseMapper<Reposit
|
||||
if (repositoryService.isSupported(Command.BRANCHES)) {
|
||||
linksBuilder.single(link("branches", resourceLinks.branchCollection().self(target.getNamespace(), target.getName())));
|
||||
}
|
||||
if (repositoryService.isSupported(Feature.INCOMING)) {
|
||||
linksBuilder.single(link("incomingChangesets", resourceLinks.incoming().changesets(target.getNamespace(), target.getName())));
|
||||
linksBuilder.single(link("incomingDiff", resourceLinks.incoming().diff(target.getNamespace(), target.getName())));
|
||||
}
|
||||
}
|
||||
linksBuilder.single(link("changesets", resourceLinks.changeset().all(target.getNamespace(), target.getName())));
|
||||
linksBuilder.single(link("sources", resourceLinks.source().selfWithoutRevision(target.getNamespace(), target.getName())));
|
||||
linksBuilder.single(link("incomingChangesets", resourceLinks.incoming().changesets(target.getNamespace(), target.getName())));
|
||||
linksBuilder.single(link("incomingDiff", resourceLinks.incoming().diff(target.getNamespace(), target.getName())));
|
||||
target.add(linksBuilder.build());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user