mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-06 04:10:52 +01:00
Added force to push command for git and hg repos
Committed-by: Rene Pfeuffer <rene.pfeuffer@cloudogu.com>
This commit is contained in:
committed by
René Pfeuffer
parent
a608a0df80
commit
b2472d85d0
@@ -26,25 +26,22 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.javahg.Changeset;
|
||||
import org.javahg.commands.ExecutionException;
|
||||
import com.google.common.base.Strings;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.repository.HgRepositoryHandler;
|
||||
import sonia.scm.repository.api.ImportFailedException;
|
||||
import sonia.scm.repository.api.PushFailedException;
|
||||
import sonia.scm.repository.api.PushResponse;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class HgPushCommand extends AbstractHgPushOrPullCommand implements PushCommand {
|
||||
@@ -74,9 +71,17 @@ public class HgPushCommand extends AbstractHgPushOrPullCommand implements PushCo
|
||||
List<Changeset> result;
|
||||
|
||||
try {
|
||||
result = org.javahg.commands.PushCommand.on(open()).execute(url);
|
||||
result = builder.call(() -> {
|
||||
org.javahg.commands.PushCommand hgPush = org.javahg.commands.PushCommand.on(open());
|
||||
|
||||
if (request.isForce()) {
|
||||
hgPush.force();
|
||||
}
|
||||
|
||||
return hgPush.execute(url);
|
||||
});
|
||||
} catch (ExecutionException ex) {
|
||||
throw new ImportFailedException(entity(getRepository()).build(), "could not execute pull command", ex);
|
||||
throw new PushFailedException(getRepository());
|
||||
}
|
||||
|
||||
return new PushResponse(result.size());
|
||||
|
||||
@@ -64,7 +64,8 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider {
|
||||
public static final Set<Feature> FEATURES = EnumSet.of(
|
||||
Feature.COMBINED_DEFAULT_BRANCH,
|
||||
Feature.MODIFICATIONS_BETWEEN_REVISIONS,
|
||||
Feature.INCOMING_REVISION
|
||||
Feature.INCOMING_REVISION,
|
||||
Feature.FORCE_PUSH
|
||||
);
|
||||
|
||||
private final Injector commandInjector;
|
||||
|
||||
Reference in New Issue
Block a user