mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-02 10:20:51 +01:00
Assisted Injection for commands
Co-authored-by: Eduard Heimbuch<eduard.heimbuch@cloudogu.com> Co-authored-by: Laura Gorzitze<laura.gorzitze@cloudogu.com> Pushed-by: Eduard Heimbuch<eduard.heimbuch@cloudogu.com> Pushed-by: Laura Gorzitze<laura.gorzitze@cloudogu.com>
This commit is contained in:
2
gradle/changelog/assissted_injection_for_command.yaml
Normal file
2
gradle/changelog/assissted_injection_for_command.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
- type: fixed
|
||||
description: Remove bottleneck by switching to assisted injection for command
|
||||
@@ -28,6 +28,7 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
@@ -66,7 +67,7 @@ public class GitBlameCommand extends AbstractGitCommand implements BlameCommand
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
@Inject
|
||||
public GitBlameCommand(GitContext context)
|
||||
public GitBlameCommand(@Assisted GitContext context)
|
||||
{
|
||||
super(context);
|
||||
}
|
||||
@@ -148,4 +149,9 @@ public class GitBlameCommand extends AbstractGitCommand implements BlameCommand
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
BlameCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.CannotDeleteCurrentBranchException;
|
||||
@@ -71,7 +72,10 @@ public class GitBranchCommand extends AbstractGitCommand implements BranchComman
|
||||
private final GitChangesetConverterFactory converterFactory;
|
||||
|
||||
@Inject
|
||||
GitBranchCommand(GitContext context, HookContextFactory hookContextFactory, ScmEventBus eventBus, GitChangesetConverterFactory converterFactory) {
|
||||
GitBranchCommand(@Assisted GitContext context,
|
||||
HookContextFactory hookContextFactory,
|
||||
ScmEventBus eventBus,
|
||||
GitChangesetConverterFactory converterFactory) {
|
||||
super(context);
|
||||
this.hookContextFactory = hookContextFactory;
|
||||
this.eventBus = eventBus;
|
||||
@@ -201,4 +205,8 @@ public class GitBranchCommand extends AbstractGitCommand implements BranchComman
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
BranchCommand create(GitContext context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
@@ -46,7 +47,7 @@ import static sonia.scm.NotFoundException.notFound;
|
||||
public class GitBranchDetailsCommand extends AbstractGitCommand implements BranchDetailsCommand {
|
||||
|
||||
@Inject
|
||||
GitBranchDetailsCommand(GitContext context) {
|
||||
GitBranchDetailsCommand(@Assisted GitContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -97,4 +98,9 @@ public class GitBranchDetailsCommand extends AbstractGitCommand implements Branc
|
||||
throw new InternalRepositoryException(context.getRepository(), "could not compute ahead/behind", e);
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
BranchDetailsCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
@@ -55,7 +56,7 @@ public class GitBranchesCommand extends AbstractGitCommand implements BranchesCo
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GitBranchesCommand.class);
|
||||
|
||||
@Inject
|
||||
public GitBranchesCommand(GitContext context) {
|
||||
public GitBranchesCommand(@Assisted GitContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -120,5 +121,10 @@ public class GitBranchesCommand extends AbstractGitCommand implements BranchesCo
|
||||
Optional<Ref> getRepositoryHeadRef(Git git) {
|
||||
return GitUtil.getRepositoryHeadRef(git.getRepository());
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
BranchesCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.google.common.base.Stopwatch;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.attributes.Attributes;
|
||||
import org.eclipse.jgit.lfs.LfsPointer;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
@@ -113,7 +114,7 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
private int resultCount = 0;
|
||||
|
||||
@Inject
|
||||
public GitBrowseCommand(GitContext context, LfsBlobStoreFactory lfsBlobStoreFactory, SyncAsyncExecutorProvider executorProvider) {
|
||||
public GitBrowseCommand(@Assisted GitContext context, LfsBlobStoreFactory lfsBlobStoreFactory, SyncAsyncExecutorProvider executorProvider) {
|
||||
this(context, lfsBlobStoreFactory, executorProvider.createExecutorWithDefaultTimeout());
|
||||
}
|
||||
|
||||
@@ -560,4 +561,9 @@ public class GitBrowseCommand extends AbstractGitCommand
|
||||
children.add(treeEntry);
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
BrowseCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,10 +23,12 @@
|
||||
*/
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import sonia.scm.ContextEntry;
|
||||
import sonia.scm.repository.api.BundleResponse;
|
||||
import sonia.scm.repository.api.ExportFailedException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
@@ -38,7 +40,8 @@ public class GitBundleCommand extends AbstractGitCommand implements BundleComman
|
||||
|
||||
private static final String TAR_ARCHIVE = "tar";
|
||||
|
||||
public GitBundleCommand(GitContext context) {
|
||||
@Inject
|
||||
public GitBundleCommand(@Assisted GitContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -66,4 +69,9 @@ public class GitBundleCommand extends AbstractGitCommand implements BundleComman
|
||||
private boolean shouldIncludeFile(Path filePath) {
|
||||
return !filePath.getFileName().toString().equals("config");
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
BundleCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
import org.eclipse.jgit.lfs.LfsPointer;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
@@ -63,7 +64,7 @@ public class GitCatCommand extends AbstractGitCommand implements CatCommand {
|
||||
private final LfsBlobStoreFactory lfsBlobStoreFactory;
|
||||
|
||||
@Inject
|
||||
public GitCatCommand(GitContext context, LfsBlobStoreFactory lfsBlobStoreFactory) {
|
||||
public GitCatCommand(@Assisted GitContext context, LfsBlobStoreFactory lfsBlobStoreFactory) {
|
||||
super(context);
|
||||
this.lfsBlobStoreFactory = lfsBlobStoreFactory;
|
||||
}
|
||||
@@ -225,4 +226,9 @@ public class GitCatCommand extends AbstractGitCommand implements CatCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
CatCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
@@ -47,7 +48,7 @@ public class GitChangesetsCommand extends AbstractGitCommand implements Changese
|
||||
private final GitChangesetConverterFactory converterFactory;
|
||||
|
||||
@Inject
|
||||
GitChangesetsCommand(GitContext context, GitChangesetConverterFactory converterFactory) {
|
||||
GitChangesetsCommand(@Assisted GitContext context, GitChangesetConverterFactory converterFactory) {
|
||||
super(context);
|
||||
this.converterFactory = converterFactory;
|
||||
}
|
||||
@@ -122,4 +123,9 @@ public class GitChangesetsCommand extends AbstractGitCommand implements Changese
|
||||
return Long.compare(commitTime1, commitTime2);
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
ChangesetsCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.diff.DiffEntry;
|
||||
import org.eclipse.jgit.diff.DiffFormatter;
|
||||
import org.eclipse.jgit.util.QuotedString;
|
||||
@@ -43,7 +44,7 @@ import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
public class GitDiffCommand extends AbstractGitCommand implements DiffCommand {
|
||||
|
||||
@Inject
|
||||
GitDiffCommand(GitContext context) {
|
||||
GitDiffCommand(@Assisted GitContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -185,4 +186,9 @@ public class GitDiffCommand extends AbstractGitCommand implements DiffCommand {
|
||||
target.flush();
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
DiffCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.diff.DiffEntry;
|
||||
import org.eclipse.jgit.diff.DiffFormatter;
|
||||
import org.eclipse.jgit.errors.AmbiguousObjectException;
|
||||
@@ -50,7 +51,7 @@ import static java.util.Optional.ofNullable;
|
||||
public class GitDiffResultCommand extends AbstractGitCommand implements DiffResultCommand {
|
||||
|
||||
@Inject
|
||||
GitDiffResultCommand(GitContext context) {
|
||||
GitDiffResultCommand(@Assisted GitContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -197,4 +198,9 @@ public class GitDiffResultCommand extends AbstractGitCommand implements DiffResu
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
DiffResultCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import sonia.scm.repository.api.FileLock;
|
||||
import sonia.scm.repository.api.LockCommandResult;
|
||||
import sonia.scm.repository.api.UnlockCommandResult;
|
||||
@@ -39,7 +40,7 @@ public class GitFileLockCommand implements FileLockCommand {
|
||||
private final GitFileLockStoreFactory lockStoreFactory;
|
||||
|
||||
@Inject
|
||||
public GitFileLockCommand(GitContext context, GitFileLockStoreFactory lockStoreFactory) {
|
||||
public GitFileLockCommand(@Assisted GitContext context, GitFileLockStoreFactory lockStoreFactory) {
|
||||
this.context = context;
|
||||
this.lockStoreFactory = lockStoreFactory;
|
||||
}
|
||||
@@ -73,4 +74,9 @@ public class GitFileLockCommand implements FileLockCommand {
|
||||
private GitFileLockStore getLockStore() {
|
||||
return lockStoreFactory.create(context.getRepository());
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
FileLockCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.api.LogCommand;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
@@ -45,7 +46,7 @@ public class GitIncomingCommand extends AbstractGitIncomingOutgoingCommand
|
||||
implements IncomingCommand {
|
||||
|
||||
@Inject
|
||||
GitIncomingCommand(GitContext context, GitRepositoryHandler handler, GitChangesetConverterFactory converterFactory) {
|
||||
GitIncomingCommand(@Assisted GitContext context, GitRepositoryHandler handler, GitChangesetConverterFactory converterFactory) {
|
||||
super(context, handler, converterFactory);
|
||||
}
|
||||
|
||||
@@ -95,4 +96,9 @@ public class GitIncomingCommand extends AbstractGitIncomingOutgoingCommand
|
||||
{
|
||||
return remoteId != null;
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
IncomingCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ package sonia.scm.repository.spi;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
@@ -74,7 +75,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
*
|
||||
*/
|
||||
@Inject
|
||||
GitLogCommand(GitContext context, GitChangesetConverterFactory converterFactory)
|
||||
GitLogCommand(@Assisted GitContext context, GitChangesetConverterFactory converterFactory)
|
||||
{
|
||||
super(context);
|
||||
this.converterFactory = converterFactory;
|
||||
@@ -188,4 +189,7 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
LogCommand create(GitContext context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.MergeResult;
|
||||
import org.eclipse.jgit.api.Status;
|
||||
@@ -65,11 +66,11 @@ public class GitMergeCommand extends AbstractGitCommand implements MergeCommand
|
||||
);
|
||||
|
||||
@Inject
|
||||
GitMergeCommand(GitContext context, GitRepositoryHandler handler) {
|
||||
GitMergeCommand(@Assisted GitContext context, GitRepositoryHandler handler) {
|
||||
this(context, handler.getWorkingCopyFactory());
|
||||
}
|
||||
|
||||
GitMergeCommand(GitContext context, GitWorkingCopyFactory workingCopyFactory) {
|
||||
GitMergeCommand(@Assisted GitContext context, GitWorkingCopyFactory workingCopyFactory) {
|
||||
super(context);
|
||||
this.workingCopyFactory = workingCopyFactory;
|
||||
}
|
||||
@@ -214,4 +215,9 @@ public class GitMergeCommand extends AbstractGitCommand implements MergeCommand
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
MergeCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jgit.api.FetchCommand;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
@@ -113,7 +114,7 @@ public class GitMirrorCommand extends AbstractGitCommand implements MirrorComman
|
||||
private final LfsLoader lfsLoader;
|
||||
|
||||
@Inject
|
||||
GitMirrorCommand(GitContext context,
|
||||
GitMirrorCommand(@Assisted GitContext context,
|
||||
MirrorHttpConnectionProvider mirrorHttpConnectionProvider,
|
||||
GitChangesetConverterFactory converterFactory,
|
||||
GitTagConverter gitTagConverter,
|
||||
@@ -799,4 +800,9 @@ public class GitMirrorCommand extends AbstractGitCommand implements MirrorComman
|
||||
this.typeForLog = typeForLog;
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
MirrorCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.jgit.diff.DiffEntry;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
@@ -57,7 +58,7 @@ import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
||||
public class GitModificationsCommand extends AbstractGitCommand implements ModificationsCommand {
|
||||
|
||||
@Inject
|
||||
GitModificationsCommand(GitContext context) {
|
||||
GitModificationsCommand(@Assisted GitContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -156,4 +157,9 @@ public class GitModificationsCommand extends AbstractGitCommand implements Modif
|
||||
throw new UnsupportedModificationTypeException(entity(repository), MessageFormat.format("The modification type: {0} is not supported.", type));
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
ModificationsCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.util.concurrent.Striped;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
@@ -57,11 +58,11 @@ public class GitModifyCommand extends AbstractGitCommand implements ModifyComman
|
||||
private final GitRepositoryConfigStoreProvider gitRepositoryConfigStoreProvider;
|
||||
|
||||
@Inject
|
||||
GitModifyCommand(GitContext context, GitRepositoryHandler repositoryHandler, LfsBlobStoreFactory lfsBlobStoreFactory, GitRepositoryConfigStoreProvider gitRepositoryConfigStoreProvider) {
|
||||
GitModifyCommand(@Assisted GitContext context, GitRepositoryHandler repositoryHandler, LfsBlobStoreFactory lfsBlobStoreFactory, GitRepositoryConfigStoreProvider gitRepositoryConfigStoreProvider) {
|
||||
this(context, repositoryHandler.getWorkingCopyFactory(), lfsBlobStoreFactory, gitRepositoryConfigStoreProvider);
|
||||
}
|
||||
|
||||
GitModifyCommand(GitContext context, GitWorkingCopyFactory workingCopyFactory, LfsBlobStoreFactory lfsBlobStoreFactory, GitRepositoryConfigStoreProvider gitRepositoryConfigStoreProvider) {
|
||||
GitModifyCommand(@Assisted GitContext context, GitWorkingCopyFactory workingCopyFactory, LfsBlobStoreFactory lfsBlobStoreFactory, GitRepositoryConfigStoreProvider gitRepositoryConfigStoreProvider) {
|
||||
super(context);
|
||||
this.workingCopyFactory = workingCopyFactory;
|
||||
this.lfsBlobStoreFactory = lfsBlobStoreFactory;
|
||||
@@ -217,4 +218,9 @@ public class GitModifyCommand extends AbstractGitCommand implements ModifyComman
|
||||
throw new InternalRepositoryException(context.getRepository(), message, e);
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
ModifyCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.api.LogCommand;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
@@ -45,7 +46,7 @@ public class GitOutgoingCommand extends AbstractGitIncomingOutgoingCommand
|
||||
implements OutgoingCommand {
|
||||
|
||||
@Inject
|
||||
GitOutgoingCommand(GitContext context, GitRepositoryHandler handler, GitChangesetConverterFactory converterFactory)
|
||||
GitOutgoingCommand(@Assisted GitContext context, GitRepositoryHandler handler, GitChangesetConverterFactory converterFactory)
|
||||
{
|
||||
super(context, handler, converterFactory);
|
||||
}
|
||||
@@ -109,4 +110,9 @@ public class GitOutgoingCommand extends AbstractGitIncomingOutgoingCommand
|
||||
{
|
||||
return localId != null;
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
OutgoingCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ package sonia.scm.repository.spi;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
@@ -67,8 +68,8 @@ public class GitPullCommand extends AbstractGitPushOrPullCommand
|
||||
|
||||
@Inject
|
||||
public GitPullCommand(GitRepositoryHandler handler,
|
||||
GitContext context,
|
||||
PostReceiveRepositoryHookEventFactory postReceiveRepositoryHookEventFactory,
|
||||
@Assisted GitContext context,
|
||||
@Assisted PostReceiveRepositoryHookEventFactory postReceiveRepositoryHookEventFactory,
|
||||
LfsLoader lfsLoader,
|
||||
PullHttpConnectionProvider pullHttpConnectionProvider,
|
||||
GitRepositoryConfigStoreProvider storeProvider, GitHeadModifier gitHeadModifier) {
|
||||
@@ -266,4 +267,9 @@ public class GitPullCommand extends AbstractGitPushOrPullCommand
|
||||
return failureCount;
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
PullCommand create(GitContext context, PostReceiveRepositoryHookEventFactory postReceiveRepositoryHookEventFactory);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.repository.GitRepositoryHandler;
|
||||
@@ -37,7 +38,7 @@ public class GitPushCommand extends AbstractGitPushOrPullCommand implements Push
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GitPushCommand.class);
|
||||
|
||||
@Inject
|
||||
public GitPushCommand(GitRepositoryHandler handler, GitContext context) {
|
||||
public GitPushCommand(GitRepositoryHandler handler, @Assisted GitContext context) {
|
||||
super(handler, context);
|
||||
this.handler = handler;
|
||||
}
|
||||
@@ -51,4 +52,9 @@ public class GitPushCommand extends AbstractGitPushOrPullCommand implements Push
|
||||
|
||||
return new PushResponse(push(open(), remoteUrl, request.getUsername(), request.getPassword(), request.isForce()));
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
PushCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Injector;
|
||||
import sonia.scm.repository.Feature;
|
||||
import sonia.scm.repository.api.Command;
|
||||
@@ -69,134 +68,130 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider {
|
||||
Feature.FORCE_PUSH
|
||||
);
|
||||
|
||||
private final Injector injector;
|
||||
private final GitContext context;
|
||||
private final Injector commandInjector;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
GitRepositoryServiceProvider(Injector injector, GitContext context) {
|
||||
this.injector = injector;
|
||||
this.context = context;
|
||||
commandInjector = injector.createChildInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(GitContext.class).toInstance(context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlameCommand getBlameCommand() {
|
||||
return new GitBlameCommand(context);
|
||||
return injector.getInstance(GitBlameCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BranchesCommand getBranchesCommand() {
|
||||
return new GitBranchesCommand(context);
|
||||
return injector.getInstance(GitBranchesCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BranchCommand getBranchCommand() {
|
||||
return commandInjector.getInstance(GitBranchCommand.class);
|
||||
return injector.getInstance(GitBranchCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BrowseCommand getBrowseCommand() {
|
||||
return commandInjector.getInstance(GitBrowseCommand.class);
|
||||
return injector.getInstance(GitBrowseCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CatCommand getCatCommand() {
|
||||
return commandInjector.getInstance(GitCatCommand.class);
|
||||
return injector.getInstance(GitCatCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiffCommand getDiffCommand() {
|
||||
return new GitDiffCommand(context);
|
||||
return injector.getInstance(GitDiffCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiffResultCommand getDiffResultCommand() {
|
||||
return new GitDiffResultCommand(context);
|
||||
return injector.getInstance(GitDiffResultCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IncomingCommand getIncomingCommand() {
|
||||
return commandInjector.getInstance(GitIncomingCommand.class);
|
||||
return injector.getInstance(GitIncomingCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LogCommand getLogCommand() {
|
||||
return commandInjector.getInstance(GitLogCommand.class);
|
||||
return injector.getInstance(GitLogCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModificationsCommand getModificationsCommand() {
|
||||
return new GitModificationsCommand(context);
|
||||
return injector.getInstance(GitModificationsCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutgoingCommand getOutgoingCommand() {
|
||||
return commandInjector.getInstance(GitOutgoingCommand.class);
|
||||
return injector.getInstance(GitOutgoingCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PullCommand getPullCommand() {
|
||||
return commandInjector.getInstance(GitPullCommand.class);
|
||||
PostReceiveRepositoryHookEventFactory postReceiveRepositoryHookEventFactory = injector.getInstance(PostReceiveRepositoryHookEventFactory.Factory.class).create(context);
|
||||
return injector.getInstance(GitPullCommand.Factory.class).create(context, postReceiveRepositoryHookEventFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PushCommand getPushCommand() {
|
||||
return commandInjector.getInstance(GitPushCommand.class);
|
||||
return injector.getInstance(GitPushCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagsCommand getTagsCommand() {
|
||||
return commandInjector.getInstance(GitTagsCommand.class);
|
||||
return injector.getInstance(GitTagsCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagCommand getTagCommand() {
|
||||
return commandInjector.getInstance(GitTagCommand.class);
|
||||
return injector.getInstance(GitTagCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MergeCommand getMergeCommand() {
|
||||
return commandInjector.getInstance(GitMergeCommand.class);
|
||||
return injector.getInstance(GitMergeCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModifyCommand getModifyCommand() {
|
||||
return commandInjector.getInstance(GitModifyCommand.class);
|
||||
return injector.getInstance(GitModifyCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BundleCommand getBundleCommand() {
|
||||
return new GitBundleCommand(context);
|
||||
return injector.getInstance(GitBundleCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbundleCommand getUnbundleCommand() {
|
||||
return commandInjector.getInstance(GitUnbundleCommand.class);
|
||||
return injector.getInstance(GitUnbundleCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MirrorCommand getMirrorCommand() {
|
||||
return commandInjector.getInstance(GitMirrorCommand.class);
|
||||
return injector.getInstance(GitMirrorCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileLockCommand getFileLockCommand() {
|
||||
return commandInjector.getInstance(GitFileLockCommand.class);
|
||||
return injector.getInstance(GitFileLockCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BranchDetailsCommand getBranchDetailsCommand() {
|
||||
return commandInjector.getInstance(GitBranchDetailsCommand.class);
|
||||
return injector.getInstance(GitBranchDetailsCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangesetsCommand getChangesetsCommand() {
|
||||
return commandInjector.getInstance(GitChangesetsCommand.class);
|
||||
return injector.getInstance(GitChangesetsCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
@@ -80,7 +81,7 @@ public class GitTagCommand extends AbstractGitCommand implements TagCommand {
|
||||
private final GitChangesetConverterFactory converterFactory;
|
||||
|
||||
@Inject
|
||||
GitTagCommand(GitContext context, HookContextFactory hookContextFactory, ScmEventBus eventBus, GitChangesetConverterFactory converterFactory) {
|
||||
GitTagCommand(@Assisted GitContext context, HookContextFactory hookContextFactory, ScmEventBus eventBus, GitChangesetConverterFactory converterFactory) {
|
||||
super(context);
|
||||
this.hookContextFactory = hookContextFactory;
|
||||
this.eventBus = eventBus;
|
||||
@@ -254,4 +255,9 @@ public class GitTagCommand extends AbstractGitCommand implements TagCommand {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
TagCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
@@ -54,7 +55,7 @@ public class GitTagsCommand extends AbstractGitCommand implements TagsCommand {
|
||||
* @param context
|
||||
*/
|
||||
@Inject
|
||||
public GitTagsCommand(GitContext context, GitTagConverter gitTagConverter) {
|
||||
public GitTagsCommand(@Assisted GitContext context, GitTagConverter gitTagConverter) {
|
||||
super(context);
|
||||
this.gitTagConverter = gitTagConverter;
|
||||
}
|
||||
@@ -73,4 +74,9 @@ public class GitTagsCommand extends AbstractGitCommand implements TagsCommand {
|
||||
throw new InternalRepositoryException(repository, "could not read tags from repository", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
TagsCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
@@ -52,7 +53,7 @@ public class GitUnbundleCommand extends AbstractGitCommand implements UnbundleCo
|
||||
private final GitRepositoryHookEventFactory eventFactory;
|
||||
|
||||
@Inject
|
||||
GitUnbundleCommand(GitContext context, GitRepositoryHookEventFactory eventFactory) {
|
||||
GitUnbundleCommand(@Assisted GitContext context, GitRepositoryHookEventFactory eventFactory) {
|
||||
super(context);
|
||||
this.eventFactory = eventFactory;
|
||||
}
|
||||
@@ -107,4 +108,9 @@ public class GitUnbundleCommand extends AbstractGitCommand implements UnbundleCo
|
||||
private void unbundleRepositoryFromRequest(UnbundleCommandRequest request, Path repositoryDir) throws IOException {
|
||||
extractTar(request.getArchive().openBufferedStream(), repositoryDir).run();
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
UnbundleCommand create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.transport.FetchResult;
|
||||
import sonia.scm.ContextEntry;
|
||||
@@ -38,14 +39,14 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
class PostReceiveRepositoryHookEventFactory {
|
||||
public class PostReceiveRepositoryHookEventFactory {
|
||||
|
||||
private final ScmEventBus eventBus;
|
||||
private final GitRepositoryHookEventFactory eventFactory;
|
||||
private final GitContext context;
|
||||
|
||||
@Inject
|
||||
PostReceiveRepositoryHookEventFactory(ScmEventBus eventBus, GitRepositoryHookEventFactory eventFactory, GitContext context) {
|
||||
PostReceiveRepositoryHookEventFactory(ScmEventBus eventBus, GitRepositoryHookEventFactory eventFactory, @Assisted GitContext context) {
|
||||
this.eventBus = eventBus;
|
||||
this.eventFactory = eventFactory;
|
||||
this.context = context;
|
||||
@@ -81,4 +82,9 @@ class PostReceiveRepositoryHookEventFactory {
|
||||
.map(r -> r.getLeaf().getName().substring("refs/heads/".length()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
PostReceiveRepositoryHookEventFactory create(GitContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package sonia.scm.web;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||
import com.google.inject.servlet.ServletModule;
|
||||
import org.eclipse.jgit.transport.ScmTransportProtocol;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
@@ -34,7 +35,54 @@ import sonia.scm.api.v2.resources.GitConfigToGitConfigDtoMapper;
|
||||
import sonia.scm.api.v2.resources.GitRepositoryConfigMapper;
|
||||
import sonia.scm.plugin.Extension;
|
||||
import sonia.scm.repository.GitWorkingCopyFactory;
|
||||
import sonia.scm.repository.spi.BlameCommand;
|
||||
import sonia.scm.repository.spi.BranchCommand;
|
||||
import sonia.scm.repository.spi.BranchDetailsCommand;
|
||||
import sonia.scm.repository.spi.BranchesCommand;
|
||||
import sonia.scm.repository.spi.BrowseCommand;
|
||||
import sonia.scm.repository.spi.BundleCommand;
|
||||
import sonia.scm.repository.spi.CatCommand;
|
||||
import sonia.scm.repository.spi.ChangesetsCommand;
|
||||
import sonia.scm.repository.spi.DiffCommand;
|
||||
import sonia.scm.repository.spi.DiffResultCommand;
|
||||
import sonia.scm.repository.spi.FileLockCommand;
|
||||
import sonia.scm.repository.spi.GitBlameCommand;
|
||||
import sonia.scm.repository.spi.GitBranchCommand;
|
||||
import sonia.scm.repository.spi.GitBranchDetailsCommand;
|
||||
import sonia.scm.repository.spi.GitBranchesCommand;
|
||||
import sonia.scm.repository.spi.GitBrowseCommand;
|
||||
import sonia.scm.repository.spi.GitBundleCommand;
|
||||
import sonia.scm.repository.spi.GitCatCommand;
|
||||
import sonia.scm.repository.spi.GitChangesetsCommand;
|
||||
import sonia.scm.repository.spi.GitDiffCommand;
|
||||
import sonia.scm.repository.spi.GitDiffResultCommand;
|
||||
import sonia.scm.repository.spi.GitFileLockCommand;
|
||||
import sonia.scm.repository.spi.GitIncomingCommand;
|
||||
import sonia.scm.repository.spi.GitLogCommand;
|
||||
import sonia.scm.repository.spi.GitMergeCommand;
|
||||
import sonia.scm.repository.spi.GitMirrorCommand;
|
||||
import sonia.scm.repository.spi.GitModificationsCommand;
|
||||
import sonia.scm.repository.spi.GitModifyCommand;
|
||||
import sonia.scm.repository.spi.GitOutgoingCommand;
|
||||
import sonia.scm.repository.spi.GitPullCommand;
|
||||
import sonia.scm.repository.spi.GitPushCommand;
|
||||
import sonia.scm.repository.spi.GitTagCommand;
|
||||
import sonia.scm.repository.spi.GitTagsCommand;
|
||||
import sonia.scm.repository.spi.GitUnbundleCommand;
|
||||
import sonia.scm.repository.spi.IncomingCommand;
|
||||
import sonia.scm.repository.spi.LogCommand;
|
||||
import sonia.scm.repository.spi.MergeCommand;
|
||||
import sonia.scm.repository.spi.MirrorCommand;
|
||||
import sonia.scm.repository.spi.ModificationsCommand;
|
||||
import sonia.scm.repository.spi.ModifyCommand;
|
||||
import sonia.scm.repository.spi.OutgoingCommand;
|
||||
import sonia.scm.repository.spi.PostReceiveRepositoryHookEventFactory;
|
||||
import sonia.scm.repository.spi.PullCommand;
|
||||
import sonia.scm.repository.spi.PushCommand;
|
||||
import sonia.scm.repository.spi.SimpleGitWorkingCopyFactory;
|
||||
import sonia.scm.repository.spi.TagCommand;
|
||||
import sonia.scm.repository.spi.TagsCommand;
|
||||
import sonia.scm.repository.spi.UnbundleCommand;
|
||||
import sonia.scm.web.lfs.LfsBlobStoreFactory;
|
||||
|
||||
/**
|
||||
@@ -57,5 +105,32 @@ public class GitServletModule extends ServletModule {
|
||||
bind(GitRepositoryConfigMapper.class).to(Mappers.getMapper(GitRepositoryConfigMapper.class).getClass());
|
||||
|
||||
bind(GitWorkingCopyFactory.class).to(SimpleGitWorkingCopyFactory.class);
|
||||
|
||||
install(new FactoryModuleBuilder().implement(BranchCommand.class, GitBranchCommand.class).build(GitBranchCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(BlameCommand.class, GitBlameCommand.class).build(GitBlameCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(BranchesCommand.class, GitBranchesCommand.class).build(GitBranchesCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(BrowseCommand.class, GitBrowseCommand.class).build(GitBrowseCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(CatCommand.class, GitCatCommand.class).build(GitCatCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(DiffCommand.class, GitDiffCommand.class).build(GitDiffCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(DiffResultCommand.class, GitDiffResultCommand.class).build(GitDiffResultCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(IncomingCommand.class, GitIncomingCommand.class).build(GitIncomingCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(LogCommand.class, GitLogCommand.class).build(GitLogCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(ModificationsCommand.class, GitModificationsCommand.class).build(GitModificationsCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(OutgoingCommand.class, GitOutgoingCommand.class).build(GitOutgoingCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(PullCommand.class, GitPullCommand.class).build(GitPullCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(PostReceiveRepositoryHookEventFactory.class, PostReceiveRepositoryHookEventFactory.class).build(PostReceiveRepositoryHookEventFactory.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(PushCommand.class, GitPushCommand.class).build(GitPushCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(TagsCommand.class, GitTagsCommand.class).build(GitTagsCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(TagCommand.class, GitTagCommand.class).build(GitTagCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(MergeCommand.class, GitMergeCommand.class).build(GitMergeCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(ModifyCommand.class, GitModifyCommand.class).build(GitModifyCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(BundleCommand.class, GitBundleCommand.class).build(GitBundleCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(UnbundleCommand.class, GitUnbundleCommand.class).build(GitUnbundleCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(MirrorCommand.class, GitMirrorCommand.class).build(GitMirrorCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(FileLockCommand.class, GitFileLockCommand.class).build(GitFileLockCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(BranchDetailsCommand.class, GitBranchDetailsCommand.class).build(GitBranchDetailsCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(ChangesetsCommand.class, GitChangesetsCommand.class).build(GitChangesetsCommand.Factory.class));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ package sonia.scm.repository.spi;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
@@ -59,6 +61,7 @@ class GitRepositoryServiceProviderTest {
|
||||
}
|
||||
|
||||
private GitRepositoryServiceProvider createProvider() {
|
||||
|
||||
return new GitRepositoryServiceProvider(createParentInjector(), context);
|
||||
}
|
||||
|
||||
@@ -67,6 +70,9 @@ class GitRepositoryServiceProviderTest {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(GitRepositoryHandler.class).toInstance(handler);
|
||||
FactoryModuleBuilder builder = new FactoryModuleBuilder();
|
||||
Module module = builder.implement(PushCommand.class, GitPushCommand.class).build(GitPushCommand.Factory.class);
|
||||
install(module);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.Changeset;
|
||||
import org.javahg.commands.AnnotateCommand;
|
||||
import org.javahg.AnnotateLine;
|
||||
@@ -38,6 +39,7 @@ import sonia.scm.repository.BlameResult;
|
||||
import sonia.scm.repository.Person;
|
||||
import sonia.scm.web.HgUtil;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@@ -64,7 +66,9 @@ public class HgBlameCommand extends AbstractCommand implements BlameCommand
|
||||
* @param context
|
||||
*
|
||||
*/
|
||||
HgBlameCommand(HgCommandContext context)
|
||||
|
||||
@Inject
|
||||
HgBlameCommand(@Assisted HgCommandContext context)
|
||||
{
|
||||
super(context);
|
||||
}
|
||||
@@ -129,4 +133,9 @@ public class HgBlameCommand extends AbstractCommand implements BlameCommand
|
||||
|
||||
return blameLine;
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgBlameCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.Changeset;
|
||||
import org.javahg.commands.CommitCommand;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
@@ -49,7 +50,7 @@ public class HgBranchCommand extends AbstractWorkingCopyCommand implements Branc
|
||||
private static final Logger LOG = LoggerFactory.getLogger(HgBranchCommand.class);
|
||||
|
||||
@Inject
|
||||
HgBranchCommand(HgCommandContext context, HgRepositoryHandler handler) {
|
||||
HgBranchCommand(@Assisted HgCommandContext context, HgRepositoryHandler handler) {
|
||||
this(context, handler.getWorkingCopyFactory());
|
||||
}
|
||||
|
||||
@@ -107,4 +108,7 @@ public class HgBranchCommand extends AbstractWorkingCopyCommand implements Branc
|
||||
.execute();
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgBranchCommand create(HgCommandContext context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.Changeset;
|
||||
import org.javahg.commands.ExecutionException;
|
||||
import org.javahg.commands.LogCommand;
|
||||
@@ -46,7 +47,7 @@ public class HgBranchDetailsCommand implements BranchDetailsCommand {
|
||||
private final HgCommandContext context;
|
||||
|
||||
@Inject
|
||||
HgBranchDetailsCommand(HgCommandContext context) {
|
||||
HgBranchDetailsCommand(@Assisted HgCommandContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@@ -82,4 +83,7 @@ public class HgBranchDetailsCommand implements BranchDetailsCommand {
|
||||
return logCommand.execute();
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgBranchDetailsCommand create(HgCommandContext context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,11 +26,13 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.Changeset;
|
||||
import com.google.common.collect.Lists;
|
||||
import sonia.scm.repository.Branch;
|
||||
import sonia.scm.repository.Person;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -51,7 +53,8 @@ public class HgBranchesCommand extends AbstractCommand
|
||||
* @param context
|
||||
*
|
||||
*/
|
||||
public HgBranchesCommand(HgCommandContext context)
|
||||
@Inject
|
||||
public HgBranchesCommand(@Assisted HgCommandContext context)
|
||||
{
|
||||
super(context);
|
||||
}
|
||||
@@ -82,4 +85,9 @@ public class HgBranchesCommand extends AbstractCommand
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgBranchesCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.Changeset;
|
||||
import org.javahg.commands.LogCommand;
|
||||
import com.google.common.base.MoreObjects;
|
||||
@@ -34,6 +35,7 @@ import sonia.scm.repository.BrowserResult;
|
||||
import sonia.scm.repository.FileObject;
|
||||
import sonia.scm.repository.spi.javahg.HgFileviewCommand;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
|
||||
import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
||||
@@ -55,7 +57,9 @@ public class HgBrowseCommand extends AbstractCommand implements BrowseCommand
|
||||
* @param context
|
||||
*
|
||||
*/
|
||||
public HgBrowseCommand(HgCommandContext context)
|
||||
|
||||
@Inject
|
||||
public HgBrowseCommand(@Assisted HgCommandContext context)
|
||||
{
|
||||
super(context);
|
||||
}
|
||||
@@ -100,4 +104,9 @@ public class HgBrowseCommand extends AbstractCommand implements BrowseCommand
|
||||
.orElseThrow(() -> notFound(entity("File", request.getPath()).in("Revision", revision).in(getRepository())));
|
||||
return new BrowserResult(c == null? "tip": c.getNode(), revision, file);
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgBrowseCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,10 +24,12 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import sonia.scm.ContextEntry;
|
||||
import sonia.scm.repository.api.BundleResponse;
|
||||
import sonia.scm.repository.api.ExportFailedException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
@@ -40,8 +42,8 @@ public class HgBundleCommand implements BundleCommand {
|
||||
private static final String TAR_ARCHIVE = "tar";
|
||||
private final HgCommandContext context;
|
||||
|
||||
|
||||
public HgBundleCommand(HgCommandContext context) {
|
||||
@Inject
|
||||
public HgBundleCommand(@Assisted HgCommandContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@@ -65,4 +67,9 @@ public class HgBundleCommand implements BundleCommand {
|
||||
public String getFileExtension() {
|
||||
return TAR_ARCHIVE;
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgBundleCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.commands.ExecutionException;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.common.io.Closeables;
|
||||
@@ -33,6 +34,7 @@ import sonia.scm.ContextEntry;
|
||||
import sonia.scm.repository.InternalRepositoryException;
|
||||
import sonia.scm.web.HgUtil;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -41,7 +43,8 @@ public class HgCatCommand extends AbstractCommand implements CatCommand {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(HgCatCommand.class);
|
||||
|
||||
HgCatCommand(HgCommandContext context) {
|
||||
@Inject
|
||||
HgCatCommand(@Assisted HgCommandContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -69,4 +72,9 @@ public class HgCatCommand extends AbstractCommand implements CatCommand {
|
||||
throw new InternalRepositoryException(ContextEntry.ContextBuilder.entity(getRepository()), "could not execute cat command", e);
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgCatCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,16 +24,19 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.spi.javahg.HgLogChangesetCommand;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Optional;
|
||||
|
||||
import static sonia.scm.repository.spi.javahg.HgLogChangesetCommand.on;
|
||||
|
||||
public class HgChangesetsCommand extends AbstractCommand implements ChangesetsCommand {
|
||||
|
||||
public HgChangesetsCommand(HgCommandContext context) {
|
||||
@Inject
|
||||
public HgChangesetsCommand(@Assisted HgCommandContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -56,4 +59,9 @@ public class HgChangesetsCommand extends AbstractCommand implements ChangesetsCo
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgChangesetsCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.Repository;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.io.ByteStreams;
|
||||
@@ -33,6 +34,7 @@ import sonia.scm.repository.spi.javahg.HgDiffInternalCommand;
|
||||
import sonia.scm.web.HgUtil;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -42,7 +44,8 @@ import java.io.OutputStream;
|
||||
*/
|
||||
public class HgDiffCommand extends AbstractCommand implements DiffCommand {
|
||||
|
||||
HgDiffCommand(HgCommandContext context) {
|
||||
@Inject
|
||||
HgDiffCommand(@Assisted HgCommandContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -97,4 +100,9 @@ public class HgDiffCommand extends AbstractCommand implements DiffCommand {
|
||||
return cmd.stream();
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgDiffCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,19 +24,22 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.commands.ExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.repository.HealthCheckFailure;
|
||||
import sonia.scm.repository.HealthCheckResult;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
|
||||
public class HgFullHealthCheckCommand extends AbstractCommand implements FullHealthCheckCommand {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(HgFullHealthCheckCommand.class);
|
||||
|
||||
public HgFullHealthCheckCommand(HgCommandContext context) {
|
||||
@Inject
|
||||
public HgFullHealthCheckCommand(@Assisted HgCommandContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -52,4 +55,9 @@ public class HgFullHealthCheckCommand extends AbstractCommand implements FullHea
|
||||
"hg verify failed", "The check 'hg verify' failed for the repository."));
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgFullHealthCheckCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.commands.ExecutionException;
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
@@ -60,7 +61,7 @@ public class HgIncomingCommand extends AbstractCommand
|
||||
* @param handler
|
||||
*/
|
||||
@Inject
|
||||
HgIncomingCommand(HgCommandContext context, HgRepositoryHandler handler)
|
||||
HgIncomingCommand(@Assisted HgCommandContext context, HgRepositoryHandler handler)
|
||||
{
|
||||
super(context);
|
||||
this.handler = handler;
|
||||
@@ -120,4 +121,9 @@ public class HgIncomingCommand extends AbstractCommand
|
||||
|
||||
/** Field description */
|
||||
private HgRepositoryHandler handler;
|
||||
|
||||
public interface Factory {
|
||||
HgIncomingCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.commands.LogCommand;
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.HgRepositoryFactory;
|
||||
@@ -34,13 +35,13 @@ import javax.inject.Inject;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
class HgLazyChangesetResolver implements Callable<Iterable<Changeset>> {
|
||||
public class HgLazyChangesetResolver implements Callable<Iterable<Changeset>> {
|
||||
|
||||
private final HgRepositoryFactory factory;
|
||||
private final Repository repository;
|
||||
|
||||
@Inject
|
||||
HgLazyChangesetResolver(HgRepositoryFactory factory, HgCommandContext context) {
|
||||
HgLazyChangesetResolver(HgRepositoryFactory factory, @Assisted HgCommandContext context) {
|
||||
this.factory = factory;
|
||||
this.repository = context.getScmRepository();
|
||||
}
|
||||
@@ -57,4 +58,9 @@ class HgLazyChangesetResolver implements Callable<Iterable<Changeset>> {
|
||||
.iterator();
|
||||
return () -> iterator;
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgLazyChangesetResolver create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,17 +26,20 @@ package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
import sonia.scm.repository.spi.javahg.HgLogChangesetCommand;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class HgLogCommand extends AbstractCommand implements LogCommand {
|
||||
|
||||
HgLogCommand(HgCommandContext context) {
|
||||
@Inject
|
||||
HgLogCommand(@Assisted HgCommandContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -189,4 +192,9 @@ public class HgLogCommand extends AbstractCommand implements LogCommand {
|
||||
private HgLogChangesetCommand on(org.javahg.Repository repository) {
|
||||
return HgLogChangesetCommand.on(repository, getContext().getConfig());
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgLogCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,17 +24,20 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import sonia.scm.repository.Modification;
|
||||
import sonia.scm.repository.Modifications;
|
||||
import sonia.scm.repository.spi.javahg.HgLogChangesetCommand;
|
||||
import sonia.scm.repository.spi.javahg.StateCommand;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
public class HgModificationsCommand extends AbstractCommand implements ModificationsCommand {
|
||||
|
||||
HgModificationsCommand(HgCommandContext context) {
|
||||
@Inject
|
||||
HgModificationsCommand(@Assisted HgCommandContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -52,4 +55,9 @@ public class HgModificationsCommand extends AbstractCommand implements Modificat
|
||||
StateCommand stateCommand = new StateCommand(repository);
|
||||
return new Modifications(baseRevision, revision, stateCommand.call(baseRevision, revision));
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgModificationsCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.Changeset;
|
||||
import org.javahg.Repository;
|
||||
import org.javahg.commands.AddCommand;
|
||||
@@ -54,7 +55,7 @@ public class HgModifyCommand extends AbstractWorkingCopyCommand implements Modif
|
||||
private static final Logger LOG = LoggerFactory.getLogger(HgModifyCommand.class);
|
||||
|
||||
@Inject
|
||||
public HgModifyCommand(HgCommandContext context, HgRepositoryHandler handler) {
|
||||
public HgModifyCommand(@Assisted HgCommandContext context, HgRepositoryHandler handler) {
|
||||
super(context, handler.getWorkingCopyFactory());
|
||||
}
|
||||
|
||||
@@ -144,4 +145,9 @@ public class HgModifyCommand extends AbstractWorkingCopyCommand implements Modif
|
||||
private void throwInternalRepositoryException(String message, Exception e) {
|
||||
throw new InternalRepositoryException(context.getScmRepository(), message, e);
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgModifyCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ package sonia.scm.repository.spi;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.commands.ExecutionException;
|
||||
import sonia.scm.repository.Changeset;
|
||||
import sonia.scm.repository.ChangesetPagingResult;
|
||||
@@ -60,7 +61,7 @@ public class HgOutgoingCommand extends AbstractCommand
|
||||
* @param handler
|
||||
*/
|
||||
@Inject
|
||||
HgOutgoingCommand(HgCommandContext context, HgRepositoryHandler handler)
|
||||
HgOutgoingCommand(@Assisted HgCommandContext context, HgRepositoryHandler handler)
|
||||
{
|
||||
super(context);
|
||||
this.handler = handler;
|
||||
@@ -120,4 +121,8 @@ public class HgOutgoingCommand extends AbstractCommand
|
||||
|
||||
/** Field description */
|
||||
private HgRepositoryHandler handler;
|
||||
|
||||
public interface Factory {
|
||||
HgOutgoingCommand create(HgCommandContext context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.Changeset;
|
||||
import org.javahg.commands.ExecutionException;
|
||||
import com.google.common.base.Strings;
|
||||
@@ -50,10 +51,10 @@ public class HgPullCommand extends AbstractHgPushOrPullCommand implements PullCo
|
||||
|
||||
@Inject
|
||||
public HgPullCommand(HgRepositoryHandler handler,
|
||||
HgCommandContext context,
|
||||
@Assisted HgCommandContext context,
|
||||
ScmEventBus eventBus,
|
||||
HgLazyChangesetResolver changesetResolver,
|
||||
HgRepositoryHookEventFactory eventFactory,
|
||||
@Assisted HgLazyChangesetResolver changesetResolver,
|
||||
@Assisted HgRepositoryHookEventFactory eventFactory,
|
||||
TemporaryConfigFactory configFactory
|
||||
) {
|
||||
super(handler, context);
|
||||
@@ -92,4 +93,7 @@ public class HgPullCommand extends AbstractHgPushOrPullCommand implements PullCo
|
||||
eventBus.post(eventFactory.createEvent(context, changesetResolver));
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgPullCommand create(HgCommandContext context, HgLazyChangesetResolver hgLazyChangesetResolver, HgRepositoryHookEventFactory hgRepositoryHookEventFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ package sonia.scm.repository.spi;
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.Changeset;
|
||||
import org.javahg.commands.ExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
@@ -51,7 +52,7 @@ public class HgPushCommand extends AbstractHgPushOrPullCommand implements PushCo
|
||||
private final TemporaryConfigFactory configFactory;
|
||||
|
||||
@Inject
|
||||
public HgPushCommand(HgRepositoryHandler handler, HgCommandContext context, TemporaryConfigFactory configFactory) {
|
||||
public HgPushCommand(HgRepositoryHandler handler, @Assisted HgCommandContext context, TemporaryConfigFactory configFactory) {
|
||||
super(handler, context);
|
||||
this.configFactory = configFactory;
|
||||
}
|
||||
@@ -86,4 +87,9 @@ public class HgPushCommand extends AbstractHgPushOrPullCommand implements PushCo
|
||||
|
||||
return new PushResponse(result.size());
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgPushCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import sonia.scm.repository.RepositoryHookEvent;
|
||||
import sonia.scm.repository.Tag;
|
||||
import sonia.scm.repository.api.HookContext;
|
||||
@@ -36,7 +37,7 @@ import static sonia.scm.repository.RepositoryHookType.POST_RECEIVE;
|
||||
import static sonia.scm.repository.spi.HgBranchesTagsExtractor.extractBranches;
|
||||
import static sonia.scm.repository.spi.HgBranchesTagsExtractor.extractTags;
|
||||
|
||||
class HgRepositoryHookEventFactory {
|
||||
public class HgRepositoryHookEventFactory {
|
||||
|
||||
private final HookContextFactory hookContextFactory;
|
||||
|
||||
@@ -45,11 +46,16 @@ class HgRepositoryHookEventFactory {
|
||||
this.hookContextFactory = hookContextFactory;
|
||||
}
|
||||
|
||||
RepositoryHookEvent createEvent(HgCommandContext hgContext, HgLazyChangesetResolver changesetResolver) {
|
||||
RepositoryHookEvent createEvent(@Assisted HgCommandContext hgContext, HgLazyChangesetResolver changesetResolver) {
|
||||
List<String> branches = extractBranches(hgContext);
|
||||
List<Tag> tags = extractTags(hgContext);
|
||||
HgImportHookContextProvider contextProvider = new HgImportHookContextProvider(branches, tags, changesetResolver);
|
||||
HookContext context = hookContextFactory.createContext(contextProvider, hgContext.getScmRepository());
|
||||
return new RepositoryHookEvent(context, hgContext.getScmRepository(), POST_RECEIVE);
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgRepositoryHookEventFactory create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Injector;
|
||||
import sonia.scm.repository.Feature;
|
||||
import sonia.scm.repository.api.Command;
|
||||
@@ -68,16 +67,11 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider {
|
||||
Feature.FORCE_PUSH
|
||||
);
|
||||
|
||||
private final Injector commandInjector;
|
||||
private final HgCommandContext context;
|
||||
private final Injector injector;
|
||||
|
||||
HgRepositoryServiceProvider(Injector injector, HgCommandContext context) {
|
||||
this.commandInjector = injector.createChildInjector(new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(HgCommandContext.class).toInstance(context);
|
||||
}
|
||||
});
|
||||
this.injector = injector;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@@ -88,42 +82,42 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider {
|
||||
|
||||
@Override
|
||||
public HgBlameCommand getBlameCommand() {
|
||||
return new HgBlameCommand(context);
|
||||
return injector.getInstance(HgBlameCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BranchesCommand getBranchesCommand() {
|
||||
return new HgBranchesCommand(context);
|
||||
return injector.getInstance(HgBranchesCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BranchCommand getBranchCommand() {
|
||||
return commandInjector.getInstance(HgBranchCommand.class);
|
||||
return injector.getInstance(HgBranchCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HgBrowseCommand getBrowseCommand() {
|
||||
return new HgBrowseCommand(context);
|
||||
return injector.getInstance(HgBrowseCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HgCatCommand getCatCommand() {
|
||||
return new HgCatCommand(context);
|
||||
return injector.getInstance(HgCatCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HgDiffCommand getDiffCommand() {
|
||||
return new HgDiffCommand(context);
|
||||
return injector.getInstance(HgDiffCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IncomingCommand getIncomingCommand() {
|
||||
return commandInjector.getInstance(HgIncomingCommand.class);
|
||||
return injector.getInstance(HgIncomingCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HgLogCommand getLogCommand() {
|
||||
return new HgLogCommand(context);
|
||||
return injector.getInstance(HgLogCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,27 +128,29 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider {
|
||||
*/
|
||||
@Override
|
||||
public ModificationsCommand getModificationsCommand() {
|
||||
return new HgModificationsCommand(context);
|
||||
return injector.getInstance(HgModificationsCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OutgoingCommand getOutgoingCommand() {
|
||||
return commandInjector.getInstance(HgOutgoingCommand.class);
|
||||
return injector.getInstance(HgOutgoingCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PullCommand getPullCommand() {
|
||||
return commandInjector.getInstance(HgPullCommand.class);
|
||||
HgLazyChangesetResolver hgLazyChangesetResolver = injector.getInstance(HgLazyChangesetResolver.Factory.class).create(context);
|
||||
HgRepositoryHookEventFactory hgRepositoryHookEventFactory = injector.getInstance(HgRepositoryHookEventFactory.Factory.class).create(context);
|
||||
return injector.getInstance(HgPullCommand.Factory.class).create(context, hgLazyChangesetResolver, hgRepositoryHookEventFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PushCommand getPushCommand() {
|
||||
return commandInjector.getInstance(HgPushCommand.class);
|
||||
return injector.getInstance(HgPushCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModifyCommand getModifyCommand() {
|
||||
return commandInjector.getInstance(HgModifyCommand.class);
|
||||
return injector.getInstance(HgModifyCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,36 +165,36 @@ public class HgRepositoryServiceProvider extends RepositoryServiceProvider {
|
||||
|
||||
@Override
|
||||
public TagsCommand getTagsCommand() {
|
||||
return new HgTagsCommand(context);
|
||||
return injector.getInstance(HgTagsCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TagCommand getTagCommand() {
|
||||
return commandInjector.getInstance(HgTagCommand.class);
|
||||
return injector.getInstance(HgTagCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BundleCommand getBundleCommand() {
|
||||
return new HgBundleCommand(context);
|
||||
return injector.getInstance(HgBundleCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnbundleCommand getUnbundleCommand() {
|
||||
return commandInjector.getInstance(HgUnbundleCommand.class);
|
||||
return injector.getInstance(HgUnbundleCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FullHealthCheckCommand getFullHealthCheckCommand() {
|
||||
return new HgFullHealthCheckCommand(context);
|
||||
return injector.getInstance(HgFullHealthCheckCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BranchDetailsCommand getBranchDetailsCommand() {
|
||||
return new HgBranchDetailsCommand(context);
|
||||
return injector.getInstance(HgBranchDetailsCommand.Factory.class).create(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChangesetsCommand getChangesetsCommand() {
|
||||
return new HgChangesetsCommand(context);
|
||||
return injector.getInstance(HgChangesetsCommand.Factory.class).create(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.javahg.Repository;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
@@ -44,7 +45,7 @@ public class HgTagCommand extends AbstractWorkingCopyCommand implements TagComma
|
||||
public static final String DEFAULT_BRANCH_NAME = "default";
|
||||
|
||||
@Inject
|
||||
public HgTagCommand(HgCommandContext context, HgRepositoryHandler handler) {
|
||||
public HgTagCommand(@Assisted HgCommandContext context, HgRepositoryHandler handler) {
|
||||
this(context, handler.getWorkingCopyFactory());
|
||||
}
|
||||
|
||||
@@ -81,4 +82,9 @@ public class HgTagCommand extends AbstractWorkingCopyCommand implements TagComma
|
||||
pullChangesIntoCentralRepository(workingCopy, DEFAULT_BRANCH_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgTagCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,9 +29,11 @@ package sonia.scm.repository.spi;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import sonia.scm.repository.Tag;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -46,7 +48,9 @@ public class HgTagsCommand extends AbstractCommand implements TagsCommand {
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public HgTagsCommand(HgCommandContext context) {
|
||||
|
||||
@Inject
|
||||
public HgTagsCommand(@Assisted HgCommandContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@@ -107,4 +111,9 @@ public class HgTagsCommand extends AbstractCommand implements TagsCommand {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgTagsCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.repository.RepositoryHookEvent;
|
||||
@@ -46,7 +47,7 @@ public class HgUnbundleCommand implements UnbundleCommand {
|
||||
private final HgRepositoryHookEventFactory eventFactory;
|
||||
|
||||
@Inject
|
||||
HgUnbundleCommand(HgCommandContext context,
|
||||
HgUnbundleCommand(@Assisted HgCommandContext context,
|
||||
HgLazyChangesetResolver changesetResolver,
|
||||
HgRepositoryHookEventFactory eventFactory
|
||||
) {
|
||||
@@ -80,4 +81,9 @@ public class HgUnbundleCommand implements UnbundleCommand {
|
||||
private void unbundleRepositoryFromRequest(UnbundleCommandRequest request, Path repositoryDir) throws IOException {
|
||||
extractTar(request.getArchive().openBufferedStream(), repositoryDir).run();
|
||||
}
|
||||
|
||||
public interface Factory {
|
||||
HgUnbundleCommand create(HgCommandContext context);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,14 +26,14 @@ package sonia.scm.web;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||
import com.google.inject.servlet.ServletModule;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
import sonia.scm.api.v2.resources.HgGlobalConfigDtoToHgConfigMapper;
|
||||
import sonia.scm.api.v2.resources.HgGlobalConfigToHgGlobalConfigDtoMapper;
|
||||
import sonia.scm.api.v2.resources.HgRepositoryConfigMapper;
|
||||
import sonia.scm.plugin.Extension;
|
||||
import sonia.scm.repository.spi.HgWorkingCopyFactory;
|
||||
import sonia.scm.repository.spi.SimpleHgWorkingCopyFactory;
|
||||
import sonia.scm.repository.spi.*;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -49,5 +49,28 @@ public class HgServletModule extends ServletModule {
|
||||
bind(HgRepositoryConfigMapper.class).to(Mappers.getMapperClass(HgRepositoryConfigMapper.class));
|
||||
|
||||
bind(HgWorkingCopyFactory.class).to(SimpleHgWorkingCopyFactory.class);
|
||||
|
||||
install(new FactoryModuleBuilder().implement(BlameCommand.class, HgBlameCommand.class).build(HgBlameCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(BranchesCommand.class, HgBranchesCommand.class).build(HgBranchesCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(BranchCommand.class, HgBranchCommand.class).build(HgBranchCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(BrowseCommand.class, HgBrowseCommand.class).build(HgBrowseCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(CatCommand.class, HgCatCommand.class).build(HgCatCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(DiffCommand.class, HgDiffCommand.class).build(HgDiffCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(IncomingCommand.class, HgIncomingCommand.class).build(HgIncomingCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(LogCommand.class, HgLogCommand.class).build(HgLogCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(ModificationsCommand.class, HgModificationsCommand.class).build(HgModificationsCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(OutgoingCommand.class, HgOutgoingCommand.class).build(HgOutgoingCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(PullCommand.class, HgPullCommand.class).build(HgPullCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(HgLazyChangesetResolver.class, HgLazyChangesetResolver.class).build(HgLazyChangesetResolver.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(HgRepositoryHookEventFactory.class, HgRepositoryHookEventFactory.class).build(HgRepositoryHookEventFactory.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(PushCommand.class, HgPushCommand.class).build(HgPushCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(ModifyCommand.class, HgModifyCommand.class).build(HgModifyCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(TagsCommand.class, HgTagsCommand.class).build(HgTagsCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(TagCommand.class, HgTagCommand.class).build(HgTagCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(BundleCommand.class, HgBundleCommand.class).build(HgBundleCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(UnbundleCommand.class, HgUnbundleCommand.class).build(HgUnbundleCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(FullHealthCheckCommand.class, HgFullHealthCheckCommand.class).build(HgFullHealthCheckCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(BranchDetailsCommand.class, HgBranchDetailsCommand.class).build(HgBranchDetailsCommand.Factory.class));
|
||||
install(new FactoryModuleBuilder().implement(ChangesetsCommand.class, HgChangesetsCommand.class).build(HgChangesetsCommand.Factory.class));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user