Remove redundant constructor parameter

The repository can be retrieved from the context and does not have to be
passed through by every constructor
This commit is contained in:
René Pfeuffer
2020-05-12 15:45:58 +02:00
parent d1c6a33c67
commit d5d9690389
80 changed files with 308 additions and 425 deletions

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -77,14 +77,12 @@ class AbstractGitCommand
/**
* Constructs ...
*
* @param context
*
* @param context
* @param repository
*/
AbstractGitCommand(GitContext context,
sonia.scm.repository.Repository repository)
AbstractGitCommand(GitContext context)
{
this.repository = repository;
this.repository = context.getRepository();
this.context = context;
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -63,15 +63,12 @@ public abstract class AbstractGitIncomingOutgoingCommand
/**
* Constructs ...
*
*
* @param handler
* @param handler
* @param context
* @param repository
*/
AbstractGitIncomingOutgoingCommand(GitRepositoryHandler handler,
GitContext context, Repository repository)
AbstractGitIncomingOutgoingCommand(GitRepositoryHandler handler, GitContext context)
{
super(context, repository);
super(context);
this.handler = handler;
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -67,15 +67,12 @@ public abstract class AbstractGitPushOrPullCommand extends AbstractGitCommand
/**
* Constructs ...
*
*
* @param handler
* @param handler
* @param context
* @param repository
*/
protected AbstractGitPushOrPullCommand(GitRepositoryHandler handler,
GitContext context, sonia.scm.repository.Repository repository)
protected AbstractGitPushOrPullCommand(GitRepositoryHandler handler, GitContext context)
{
super(context, repository);
super(context);
this.handler = handler;
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -40,7 +40,6 @@ import sonia.scm.repository.BlameResult;
import sonia.scm.repository.GitUtil;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Person;
import sonia.scm.repository.Repository;
import java.io.IOException;
import java.util.ArrayList;
@@ -65,9 +64,9 @@ public class GitBlameCommand extends AbstractGitCommand implements BlameCommand
//~--- constructors ---------------------------------------------------------
public GitBlameCommand(GitContext context, Repository repository)
public GitBlameCommand(GitContext context)
{
super(context, repository);
super(context);
}
//~--- get methods ----------------------------------------------------------

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.eclipse.jgit.api.Git;
@@ -34,7 +34,6 @@ import sonia.scm.repository.GitUtil;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.PostReceiveRepositoryHookEvent;
import sonia.scm.repository.PreReceiveRepositoryHookEvent;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryHookEvent;
import sonia.scm.repository.RepositoryHookType;
import sonia.scm.repository.api.BranchRequest;
@@ -57,8 +56,8 @@ public class GitBranchCommand extends AbstractGitCommand implements BranchComman
private final HookContextFactory hookContextFactory;
private final ScmEventBus eventBus;
GitBranchCommand(GitContext context, Repository repository, HookContextFactory hookContextFactory, ScmEventBus eventBus) {
super(context, repository);
GitBranchCommand(GitContext context, HookContextFactory hookContextFactory, ScmEventBus eventBus) {
super(context);
this.hookContextFactory = hookContextFactory;
this.eventBus = eventBus;
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -37,7 +37,6 @@ import org.slf4j.LoggerFactory;
import sonia.scm.repository.Branch;
import sonia.scm.repository.GitUtil;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Repository;
import java.io.IOException;
import java.util.List;
@@ -54,9 +53,9 @@ public class GitBranchesCommand extends AbstractGitCommand implements BranchesCo
private static final Logger LOG = LoggerFactory.getLogger(GitBranchesCommand.class);
public GitBranchesCommand(GitContext context, Repository repository)
public GitBranchesCommand(GitContext context)
{
super(context, repository);
super(context);
}
//~--- get methods ----------------------------------------------------------

View File

@@ -51,7 +51,6 @@ import sonia.scm.repository.FileObject;
import sonia.scm.repository.GitSubModuleParser;
import sonia.scm.repository.GitUtil;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Repository;
import sonia.scm.repository.SubRepository;
import sonia.scm.store.Blob;
import sonia.scm.store.BlobStore;
@@ -112,8 +111,8 @@ public class GitBrowseCommand extends AbstractGitCommand
private int resultCount = 0;
public GitBrowseCommand(GitContext context, Repository repository, LfsBlobStoreFactory lfsBlobStoreFactory, SyncAsyncExecutor executor) {
super(context, repository);
public GitBrowseCommand(GitContext context, LfsBlobStoreFactory lfsBlobStoreFactory, SyncAsyncExecutor executor) {
super(context);
this.lfsBlobStoreFactory = lfsBlobStoreFactory;
this.executor = executor;
}
@@ -326,8 +325,7 @@ public class GitBrowseCommand extends AbstractGitCommand
logger.debug("read submodules of {} at {}", repository.getName(), revId);
try ( ByteArrayOutputStream baos = new ByteArrayOutputStream() ) {
new GitCatCommand(context, repository, lfsBlobStoreFactory).getContent(repo, revId,
PATH_MODULES, baos);
new GitCatCommand(context, lfsBlobStoreFactory).getContent(repo, revId, PATH_MODULES, baos);
return GitSubModuleParser.parse(baos.toString());
} catch (NotFoundException ex) {
logger.trace("could not find .gitmodules: {}", ex.getMessage());

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.eclipse.jgit.errors.MissingObjectException;
@@ -61,8 +61,8 @@ public class GitCatCommand extends AbstractGitCommand implements CatCommand {
private final LfsBlobStoreFactory lfsBlobStoreFactory;
public GitCatCommand(GitContext context, sonia.scm.repository.Repository repository, LfsBlobStoreFactory lfsBlobStoreFactory) {
super(context, repository);
public GitCatCommand(GitContext context, LfsBlobStoreFactory lfsBlobStoreFactory) {
super(context);
this.lfsBlobStoreFactory = lfsBlobStoreFactory;
}

View File

@@ -21,13 +21,12 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.diff.DiffFormatter;
import org.eclipse.jgit.util.QuotedString;
import sonia.scm.repository.Repository;
import sonia.scm.repository.api.DiffCommandBuilder;
import java.io.BufferedOutputStream;
@@ -42,8 +41,8 @@ import static java.nio.charset.StandardCharsets.UTF_8;
*/
public class GitDiffCommand extends AbstractGitCommand implements DiffCommand {
GitDiffCommand(GitContext context, Repository repository) {
super(context, repository);
GitDiffCommand(GitContext context) {
super(context);
}
@Override

View File

@@ -21,14 +21,13 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.diff.DiffFormatter;
import sonia.scm.repository.GitUtil;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Repository;
import sonia.scm.repository.api.DiffFile;
import sonia.scm.repository.api.DiffResult;
import sonia.scm.repository.api.Hunk;
@@ -40,8 +39,8 @@ import java.util.stream.Collectors;
public class GitDiffResultCommand extends AbstractGitCommand implements DiffResultCommand {
GitDiffResultCommand(GitContext context, Repository repository) {
super(context, repository);
GitDiffResultCommand(GitContext context) {
super(context);
}
public DiffResult getDiffResult(DiffCommandRequest diffCommandRequest) throws IOException {

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -30,7 +30,6 @@ import org.eclipse.jgit.api.LogCommand;
import org.eclipse.jgit.lib.ObjectId;
import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.GitRepositoryHandler;
import sonia.scm.repository.Repository;
import java.io.IOException;
@@ -47,15 +46,12 @@ public class GitIncomingCommand extends AbstractGitIncomingOutgoingCommand
/**
* Constructs ...
*
*
* @param handler
* @param handler
* @param context
* @param repository
*/
GitIncomingCommand(GitRepositoryHandler handler, GitContext context,
Repository repository)
GitIncomingCommand(GitRepositoryHandler handler, GitContext context)
{
super(handler, context, repository);
super(handler, context);
}
//~--- get methods ----------------------------------------------------------

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -77,13 +77,12 @@ public class GitLogCommand extends AbstractGitCommand implements LogCommand
* Constructs ...
*
*
* @param context
*
* @param context
* @param repository
*/
GitLogCommand(GitContext context, sonia.scm.repository.Repository repository)
GitLogCommand(GitContext context)
{
super(context, repository);
super(context);
}
//~--- get methods ----------------------------------------------------------

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import com.google.common.collect.ImmutableSet;
@@ -61,8 +61,8 @@ public class GitMergeCommand extends AbstractGitCommand implements MergeCommand
MergeStrategy.SQUASH
);
GitMergeCommand(GitContext context, sonia.scm.repository.Repository repository, GitWorkdirFactory workdirFactory) {
super(context, repository);
GitMergeCommand(GitContext context, GitWorkdirFactory workdirFactory) {
super(context);
this.workdirFactory = workdirFactory;
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import lombok.extern.slf4j.Slf4j;
@@ -35,7 +35,6 @@ import org.eclipse.jgit.treewalk.TreeWalk;
import sonia.scm.repository.GitUtil;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Modifications;
import sonia.scm.repository.Repository;
import java.io.IOException;
import java.text.MessageFormat;
@@ -47,8 +46,8 @@ import static sonia.scm.ContextEntry.ContextBuilder.entity;
@Slf4j
public class GitModificationsCommand extends AbstractGitCommand implements ModificationsCommand {
protected GitModificationsCommand(GitContext context, Repository repository) {
super(context, repository);
protected GitModificationsCommand(GitContext context) {
super(context);
}
private Modifications createModifications(TreeWalk treeWalk, RevCommit commit, RevWalk revWalk, String revision)

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import com.google.common.util.concurrent.Striped;
@@ -53,8 +53,8 @@ public class GitModifyCommand extends AbstractGitCommand implements ModifyComman
private final GitWorkdirFactory workdirFactory;
private final LfsBlobStoreFactory lfsBlobStoreFactory;
GitModifyCommand(GitContext context, Repository repository, GitWorkdirFactory workdirFactory, LfsBlobStoreFactory lfsBlobStoreFactory) {
super(context, repository);
GitModifyCommand(GitContext context, GitWorkdirFactory workdirFactory, LfsBlobStoreFactory lfsBlobStoreFactory) {
super(context);
this.workdirFactory = workdirFactory;
this.lfsBlobStoreFactory = lfsBlobStoreFactory;
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -30,7 +30,6 @@ import org.eclipse.jgit.api.LogCommand;
import org.eclipse.jgit.lib.ObjectId;
import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.GitRepositoryHandler;
import sonia.scm.repository.Repository;
import java.io.IOException;
@@ -47,15 +46,12 @@ public class GitOutgoingCommand extends AbstractGitIncomingOutgoingCommand
/**
* Constructs ...
*
*
* @param handler
* @param handler
* @param context
* @param repository
*/
GitOutgoingCommand(GitRepositoryHandler handler, GitContext context,
Repository repository)
GitOutgoingCommand(GitRepositoryHandler handler, GitContext context)
{
super(handler, context, repository);
super(handler, context);
}
//~--- get methods ----------------------------------------------------------

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -70,15 +70,12 @@ public class GitPullCommand extends AbstractGitPushOrPullCommand
/**
* Constructs ...
*
*
* @param handler
* @param handler
* @param context
* @param repository
*/
public GitPullCommand(GitRepositoryHandler handler, GitContext context,
Repository repository)
public GitPullCommand(GitRepositoryHandler handler, GitContext context)
{
super(handler, context, repository);
super(handler, context);
}
//~--- methods --------------------------------------------------------------

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -29,7 +29,6 @@ package sonia.scm.repository.spi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.repository.GitRepositoryHandler;
import sonia.scm.repository.Repository;
import sonia.scm.repository.api.PushResponse;
import java.io.IOException;
@@ -53,15 +52,12 @@ public class GitPushCommand extends AbstractGitPushOrPullCommand
/**
* Constructs ...
*
*
* @param handler
* @param handler
* @param context
* @param repository
*/
public GitPushCommand(GitRepositoryHandler handler, GitContext context,
Repository repository)
public GitPushCommand(GitRepositoryHandler handler, GitContext context)
{
super(handler, context, repository);
super(handler, context);
this.handler = handler;
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import com.google.common.collect.ImmutableSet;
@@ -58,7 +58,7 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
Command.LOG,
Command.TAGS,
Command.BRANCH,
Command.BRANCHES,
Command.BRANCHES,
Command.INCOMING,
Command.OUTGOING,
Command.PUSH,
@@ -73,7 +73,6 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
public GitRepositoryServiceProvider(GitRepositoryHandler handler, Repository repository, GitRepositoryConfigStoreProvider storeProvider, LfsBlobStoreFactory lfsBlobStoreFactory, HookContextFactory hookContextFactory, ScmEventBus eventBus, SyncAsyncExecutorProvider executorProvider) {
this.handler = handler;
this.repository = repository;
this.lfsBlobStoreFactory = lfsBlobStoreFactory;
this.hookContextFactory = hookContextFactory;
this.eventBus = eventBus;
@@ -106,7 +105,7 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public BlameCommand getBlameCommand()
{
return new GitBlameCommand(context, repository);
return new GitBlameCommand(context);
}
/**
@@ -118,7 +117,7 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public BranchesCommand getBranchesCommand()
{
return new GitBranchesCommand(context, repository);
return new GitBranchesCommand(context);
}
/**
@@ -130,7 +129,7 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public BranchCommand getBranchCommand()
{
return new GitBranchCommand(context, repository, hookContextFactory, eventBus);
return new GitBranchCommand(context, hookContextFactory, eventBus);
}
/**
@@ -142,7 +141,7 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public BrowseCommand getBrowseCommand()
{
return new GitBrowseCommand(context, repository, lfsBlobStoreFactory, executorProvider.createExecutorWithDefaultTimeout());
return new GitBrowseCommand(context, lfsBlobStoreFactory, executorProvider.createExecutorWithDefaultTimeout());
}
/**
@@ -154,7 +153,7 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public CatCommand getCatCommand()
{
return new GitCatCommand(context, repository, lfsBlobStoreFactory);
return new GitCatCommand(context, lfsBlobStoreFactory);
}
/**
@@ -166,12 +165,12 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public DiffCommand getDiffCommand()
{
return new GitDiffCommand(context, repository);
return new GitDiffCommand(context);
}
@Override
public DiffResultCommand getDiffResultCommand() {
return new GitDiffResultCommand(context, repository);
return new GitDiffResultCommand(context);
}
/**
@@ -183,7 +182,7 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public IncomingCommand getIncomingCommand()
{
return new GitIncomingCommand(handler, context, repository);
return new GitIncomingCommand(handler, context);
}
/**
@@ -195,12 +194,12 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public LogCommand getLogCommand()
{
return new GitLogCommand(context, repository);
return new GitLogCommand(context);
}
@Override
public ModificationsCommand getModificationsCommand() {
return new GitModificationsCommand(context,repository);
return new GitModificationsCommand(context);
}
/**
@@ -212,7 +211,7 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public OutgoingCommand getOutgoingCommand()
{
return new GitOutgoingCommand(handler, context, repository);
return new GitOutgoingCommand(handler, context);
}
/**
@@ -224,7 +223,7 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public PullCommand getPullCommand()
{
return new GitPullCommand(handler, context, repository);
return new GitPullCommand(handler, context);
}
/**
@@ -236,7 +235,7 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public PushCommand getPushCommand()
{
return new GitPushCommand(handler, context, repository);
return new GitPushCommand(handler, context);
}
/**
@@ -260,17 +259,17 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
@Override
public TagsCommand getTagsCommand()
{
return new GitTagsCommand(context, repository);
return new GitTagsCommand(context);
}
@Override
public MergeCommand getMergeCommand() {
return new GitMergeCommand(context, repository, handler.getWorkdirFactory());
return new GitMergeCommand(context, handler.getWorkdirFactory());
}
@Override
public ModifyCommand getModifyCommand() {
return new GitModifyCommand(context, repository, handler.getWorkdirFactory(), lfsBlobStoreFactory);
return new GitModifyCommand(context, handler.getWorkdirFactory(), lfsBlobStoreFactory);
}
@Override
@@ -285,9 +284,6 @@ public class GitRepositoryServiceProvider extends RepositoryServiceProvider
/** Field description */
private final GitRepositoryHandler handler;
/** Field description */
private final Repository repository;
private final LfsBlobStoreFactory lfsBlobStoreFactory;
private final HookContextFactory hookContextFactory;

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -37,7 +37,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.repository.GitUtil;
import sonia.scm.repository.InternalRepositoryException;
import sonia.scm.repository.Repository;
import sonia.scm.repository.Tag;
import java.io.IOException;
@@ -55,13 +54,12 @@ public class GitTagsCommand extends AbstractGitCommand implements TagsCommand
/**
* Constructs ...
*
* @param context
*
* @param context
* @param repository
*/
public GitTagsCommand(GitContext context, Repository repository)
public GitTagsCommand(GitContext context)
{
super(context, repository);
super(context);
}
//~--- get methods ----------------------------------------------------------

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -40,7 +40,7 @@ import static org.junit.Assert.assertNotNull;
/**
* Unit tests for {@link GitBlameCommand}.
*
*
* @author Sebastian Sdorra
*/
public class GitBlameCommandTest extends AbstractGitCommandTestBase
@@ -48,7 +48,7 @@ public class GitBlameCommandTest extends AbstractGitCommandTestBase
/**
* Tests blame command with default branch.
*
*
* @throws IOException
* @
*/
@@ -60,18 +60,18 @@ public class GitBlameCommandTest extends AbstractGitCommandTestBase
BlameResult result = createCommand().getBlameResult(request);
assertNotNull(result);
assertEquals(2, result.getTotal());
assertEquals(2, result.getTotal());
assertEquals("435df2f061add3589cb326cc64be9b9c3897ceca", result.getLine(0).getRevision());
assertEquals("fcd0ef1831e4002ac43ea539f4094334c79ea9ec", result.getLine(1).getRevision());
// set default branch and test again
createContext().setConfig(new GitRepositoryConfig("test-branch"));
result = createCommand().getBlameResult(request);
assertNotNull(result);
assertEquals(1, result.getTotal());
assertEquals(1, result.getTotal());
assertEquals("3f76a12f08a6ba0dc988c68b7f0b2cd190efc3c4", result.getLine(0).getRevision());
}
/**
* Method description
*
@@ -156,6 +156,6 @@ public class GitBlameCommandTest extends AbstractGitCommandTestBase
*/
private GitBlameCommand createCommand()
{
return new GitBlameCommand(createContext(), repository);
return new GitBlameCommand(createContext());
}
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.junit.Test;
@@ -107,11 +107,11 @@ public class GitBranchCommandTest extends AbstractGitCommandTestBase {
}
private GitBranchCommand createCommand() {
return new GitBranchCommand(createContext(), repository, hookContextFactory, eventBus);
return new GitBranchCommand(createContext(), hookContextFactory, eventBus);
}
private List<Branch> readBranches(GitContext context) throws IOException {
return new GitBranchesCommand(context, repository).getBranches();
return new GitBranchesCommand(context).getBranches();
}
@Test

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.eclipse.jgit.api.Git;
@@ -36,7 +36,6 @@ import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import sonia.scm.repository.Branch;
import sonia.scm.repository.GitRepositoryConfig;
import sonia.scm.repository.Repository;
import java.io.IOException;
import java.util.List;
@@ -73,7 +72,7 @@ class GitBranchesCommandTest {
@BeforeEach
void initCommand() {
master = createRef("master", "0000");
branchesCommand = new GitBranchesCommand(context, new Repository("1", "git", "space", "X")) {
branchesCommand = new GitBranchesCommand(context) {
@Override
Git createGit() {
return git;

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.junit.Test;
@@ -121,7 +121,7 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase {
@Test
public void testAsynchronousBrowse() throws IOException {
try (AsyncExecutorStepper executor = stepperAsynchronousExecutor()) {
GitBrowseCommand command = new GitBrowseCommand(createContext(), repository, null, executor);
GitBrowseCommand command = new GitBrowseCommand(createContext(), null, executor);
List<BrowserResult> updatedResults = new LinkedList<>();
BrowseCommandRequest request = new BrowseCommandRequest(updatedResults::add);
FileObject root = command.getBrowserResult(request).getFile();
@@ -354,6 +354,6 @@ public class GitBrowseCommandTest extends AbstractGitCommandTestBase {
}
private GitBrowseCommand createCommand() {
return new GitBrowseCommand(createContext(), repository, lfsBlobStoreFactory, synchronousExecutor());
return new GitBrowseCommand(createContext(), lfsBlobStoreFactory, synchronousExecutor());
}
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.hamcrest.BaseMatcher;
@@ -46,7 +46,7 @@ import static org.mockito.Mockito.when;
/**
* Unit tests for {@link GitCatCommand}.
*
*
* TODO add not found test
*
* @author Sebastian Sdorra
@@ -61,9 +61,9 @@ public class GitCatCommandTest extends AbstractGitCommandTestBase {
// without default branch, the repository head should be used
CatCommandRequest request = new CatCommandRequest();
request.setPath("a.txt");
assertEquals("a\nline for blame", execute(request));
// set default branch for repository and check again
createContext().setConfig(new GitRepositoryConfig("test-branch"));
assertEquals("a and b", execute(request));
@@ -134,7 +134,7 @@ public class GitCatCommandTest extends AbstractGitCommandTestBase {
CatCommandRequest request = new CatCommandRequest();
request.setPath("b.txt");
InputStream catResultStream = new GitCatCommand(createContext(), repository, null).getCatResultStream(request);
InputStream catResultStream = new GitCatCommand(createContext(), null).getCatResultStream(request);
assertEquals('b', catResultStream.read());
assertEquals('\n', catResultStream.read());
@@ -157,7 +157,7 @@ public class GitCatCommandTest extends AbstractGitCommandTestBase {
request.setRevision("lfs-test");
request.setPath("lfs-image.png");
InputStream catResultStream = new GitCatCommand(createContext(), repository, lfsBlobStoreFactory)
InputStream catResultStream = new GitCatCommand(createContext(), lfsBlobStoreFactory)
.getCatResultStream(request);
assertEquals('i', catResultStream.read());
@@ -174,8 +174,7 @@ public class GitCatCommandTest extends AbstractGitCommandTestBase {
try
{
new GitCatCommand(createContext(), repository, null).getCatResult(request,
baos);
new GitCatCommand(createContext(), null).getCatResult(request, baos);
}
finally
{

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.junit.Test;
@@ -78,7 +78,7 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
@Test
public void diffForOneRevisionShouldCreateDiff() throws IOException {
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext());
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
diffCommandRequest.setRevision("3f76a12f08a6ba0dc988c68b7f0b2cd190efc3c4");
ByteArrayOutputStream output = new ByteArrayOutputStream();
@@ -88,7 +88,7 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
@Test
public void diffForOneBranchShouldCreateDiff() throws IOException {
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext());
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
diffCommandRequest.setRevision("test-branch");
ByteArrayOutputStream output = new ByteArrayOutputStream();
@@ -98,7 +98,7 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
@Test
public void diffForPathShouldCreateLimitedDiff() throws IOException {
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext());
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
diffCommandRequest.setRevision("test-branch");
diffCommandRequest.setPath("a.txt");
@@ -109,7 +109,7 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
@Test
public void diffBetweenTwoBranchesShouldCreateDiff() throws IOException {
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext());
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
diffCommandRequest.setRevision("master");
diffCommandRequest.setAncestorChangeset("test-branch");
@@ -120,7 +120,7 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
@Test
public void diffBetweenTwoBranchesForPathShouldCreateLimitedDiff() throws IOException {
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext());
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
diffCommandRequest.setRevision("master");
diffCommandRequest.setAncestorChangeset("test-branch");
@@ -132,7 +132,7 @@ public class GitDiffCommandTest extends AbstractGitCommandTestBase {
@Test
public void diffBetweenTwoBranchesWithMergedIntegrationBranchShouldCreateDiffOfAllIncomingChanges() throws IOException {
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext(), repository);
GitDiffCommand gitDiffCommand = new GitDiffCommand(createContext());
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
diffCommandRequest.setRevision("partially_merged");
diffCommandRequest.setAncestorChangeset("master");

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.junit.Test;
@@ -104,7 +104,7 @@ public class GitDiffResultCommandTest extends AbstractGitCommandTestBase {
}
private DiffResult createDiffResult(String s) throws IOException {
GitDiffResultCommand gitDiffResultCommand = new GitDiffResultCommand(createContext(), repository);
GitDiffResultCommand gitDiffResultCommand = new GitDiffResultCommand(createContext());
DiffCommandRequest diffCommandRequest = new DiffCommandRequest();
diffCommandRequest.setRevision(s);

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -32,7 +32,6 @@ import org.junit.Ignore;
import org.junit.Test;
import sonia.scm.api.v2.resources.GitRepositoryConfigStoreProvider;
import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.Repository;
import sonia.scm.store.InMemoryConfigurationStoreFactory;
import java.io.IOException;
@@ -82,7 +81,7 @@ public class GitIncomingCommandTest
assertCommitsEquals(c1, cpr.getChangesets().get(0));
assertCommitsEquals(c2, cpr.getChangesets().get(1));
}
/**
* Method description
*
@@ -97,8 +96,8 @@ public class GitIncomingCommandTest
write(outgoing, outgoingDirectory, "a.txt", "content of a.txt");
commit(outgoing, "added a");
GitPullCommand pull = new GitPullCommand(handler, new GitContext(incomingDirectory, null, new GitRepositoryConfigStoreProvider(new InMemoryConfigurationStoreFactory())), incomingRepository);
GitPullCommand pull = new GitPullCommand(handler, new GitContext(incomingDirectory, incomingRepository, new GitRepositoryConfigStoreProvider(new InMemoryConfigurationStoreFactory())));
PullCommandRequest req = new PullCommandRequest();
req.setRemoteRepository(outgoingRepository);
pull.pull(req);
@@ -182,7 +181,6 @@ public class GitIncomingCommandTest
*/
private GitIncomingCommand createCommand()
{
return new GitIncomingCommand(handler, new GitContext(incomingDirectory, incomingRepository, new GitRepositoryConfigStoreProvider(new InMemoryConfigurationStoreFactory())),
this.incomingRepository);
return new GitIncomingCommand(handler, new GitContext(incomingDirectory, incomingRepository, new GitRepositoryConfigStoreProvider(new InMemoryConfigurationStoreFactory())));
}
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.junit.Test;
@@ -110,6 +110,6 @@ public class GitLogCommandAncestorTest extends AbstractGitCommandTestBase
private GitLogCommand createCommand()
{
return new GitLogCommand(createContext(), repository);
return new GitLogCommand(createContext());
}
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import com.google.common.io.Files;
@@ -180,7 +180,7 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
assertEquals("douglas.adams@hitchhiker.com", c.getAuthor().getMail());
assertEquals("added a and b files", c.getDescription());
GitModificationsCommand gitModificationsCommand = new GitModificationsCommand(createContext(), repository);
GitModificationsCommand gitModificationsCommand = new GitModificationsCommand(createContext());
Modifications modifications = gitModificationsCommand.getModifications(revision);
assertNotNull(modifications);
@@ -279,6 +279,6 @@ public class GitLogCommandTest extends AbstractGitCommandTestBase
private GitLogCommand createCommand()
{
return new GitLogCommand(createContext(), repository);
return new GitLogCommand(createContext());
}
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import com.github.sdorra.shiro.ShiroRule;
@@ -317,7 +317,7 @@ public class GitMergeCommandTest extends AbstractGitCommandTestBase {
assertThat(mergeAuthor.getName()).isEqualTo("Dirk Gently");
assertThat(message).isEqualTo("squash three commits");
GitModificationsCommand modificationsCommand = new GitModificationsCommand(createContext(), repository);
GitModificationsCommand modificationsCommand = new GitModificationsCommand(createContext());
List<String> changes = modificationsCommand.getModifications("master").getAdded();
assertThat(changes.size()).isEqualTo(3);
}
@@ -423,7 +423,7 @@ public class GitMergeCommandTest extends AbstractGitCommandTestBase {
}
private GitMergeCommand createCommand(Consumer<Git> interceptor) {
return new GitMergeCommand(createContext(), repository, new SimpleGitWorkdirFactory(new WorkdirProvider())) {
return new GitMergeCommand(createContext(), new SimpleGitWorkdirFactory(new WorkdirProvider())) {
@Override
<R, W extends GitCloneWorker<R>> R inClone(Function<Git, W> workerSupplier, GitWorkdirFactory workdirFactory, String initialBranch) {
Function<Git, W> interceptedWorkerSupplier = git -> {

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.junit.Rule;
@@ -91,7 +91,7 @@ public class GitMergeCommand_Conflict_Test extends AbstractGitCommandTestBase {
}
private MergeConflictResult computeMergeConflictResult(String branchToMerge, String targetBranch) {
GitMergeCommand gitMergeCommand = new GitMergeCommand(createContext(), repository, new SimpleGitWorkdirFactory(new WorkdirProvider()));
GitMergeCommand gitMergeCommand = new GitMergeCommand(createContext(), new SimpleGitWorkdirFactory(new WorkdirProvider()));
MergeCommandRequest mergeCommandRequest = new MergeCommandRequest();
mergeCommandRequest.setBranchToMerge(branchToMerge);
mergeCommandRequest.setTargetBranch(targetBranch);

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -42,8 +42,8 @@ public class GitModificationsCommandTest extends AbstractRemoteCommandTestBase {
@Before
public void init() {
incomingModificationsCommand = new GitModificationsCommand(new GitContext(incomingDirectory, null, null), incomingRepository);
outgoingModificationsCommand = new GitModificationsCommand(new GitContext(outgoingDirectory, null, null), outgoingRepository);
incomingModificationsCommand = new GitModificationsCommand(new GitContext(incomingDirectory, incomingRepository, null));
outgoingModificationsCommand = new GitModificationsCommand(new GitContext(outgoingDirectory, outgoingRepository, null));
}
@Test
@@ -87,13 +87,11 @@ public class GitModificationsCommandTest extends AbstractRemoteCommandTestBase {
}
void pushOutgoingAndPullIncoming() throws IOException {
GitPushCommand cmd = new GitPushCommand(handler, new GitContext(outgoingDirectory, null, null),
outgoingRepository);
GitPushCommand cmd = new GitPushCommand(handler, new GitContext(outgoingDirectory, outgoingRepository, null));
PushCommandRequest request = new PushCommandRequest();
request.setRemoteRepository(incomingRepository);
cmd.push(request);
GitPullCommand pullCommand = new GitPullCommand(handler, new GitContext(incomingDirectory, null, null),
incomingRepository);
GitPullCommand pullCommand = new GitPullCommand(handler, new GitContext(incomingDirectory, incomingRepository, null));
PullCommandRequest pullRequest = new PullCommandRequest();
pullRequest.setRemoteRepository(incomingRepository);
pullCommand.pull(pullRequest);

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import com.github.sdorra.shiro.ShiroRule;
@@ -323,7 +323,7 @@ public class GitModifyCommandTest extends AbstractGitCommandTestBase {
}
private GitModifyCommand createCommand() {
return new GitModifyCommand(createContext(), repository, new SimpleGitWorkdirFactory(new WorkdirProvider()), lfsBlobStoreFactory);
return new GitModifyCommand(createContext(), new SimpleGitWorkdirFactory(new WorkdirProvider()), lfsBlobStoreFactory);
}
@FunctionalInterface

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import com.github.sdorra.shiro.ShiroRule;
@@ -130,7 +130,7 @@ public class GitModifyCommand_LFSTest extends AbstractGitCommandTestBase {
}
private GitModifyCommand createCommand() {
return new GitModifyCommand(createContext(), repository, new SimpleGitWorkdirFactory(new WorkdirProvider()), lfsBlobStoreFactory);
return new GitModifyCommand(createContext(), new SimpleGitWorkdirFactory(new WorkdirProvider()), lfsBlobStoreFactory);
}
@Override

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
import com.github.sdorra.shiro.ShiroRule;
@@ -101,7 +101,7 @@ public class GitModifyCommand_withEmptyRepositoryTest extends AbstractGitCommand
}
private GitModifyCommand createCommand() {
return new GitModifyCommand(createContext(), repository, new SimpleGitWorkdirFactory(new WorkdirProvider()), lfsBlobStoreFactory);
return new GitModifyCommand(createContext(), new SimpleGitWorkdirFactory(new WorkdirProvider()), lfsBlobStoreFactory);
}
@FunctionalInterface

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -31,7 +31,6 @@ import org.eclipse.jgit.revwalk.RevCommit;
import org.junit.Test;
import sonia.scm.api.v2.resources.GitRepositoryConfigStoreProvider;
import sonia.scm.repository.ChangesetPagingResult;
import sonia.scm.repository.Repository;
import sonia.scm.store.InMemoryConfigurationStoreFactory;
import java.io.IOException;
@@ -43,7 +42,7 @@ import static org.junit.Assert.assertNotNull;
/**
* Unit tests for {@link OutgoingCommand}.
*
*
* @author Sebastian Sdorra
*/
public class GitOutgoingCommandTest extends AbstractRemoteCommandTestBase
@@ -98,8 +97,8 @@ public class GitOutgoingCommandTest extends AbstractRemoteCommandTestBase
commit(outgoing, "added a");
GitPushCommand push = new GitPushCommand(handler,
new GitContext(outgoingDirectory, null, null),
outgoingRepository);
new GitContext(outgoingDirectory, outgoingRepository, null)
);
PushCommandRequest req = new PushCommandRequest();
req.setRemoteRepository(incomingRepository);
@@ -152,7 +151,6 @@ public class GitOutgoingCommandTest extends AbstractRemoteCommandTestBase
*/
private GitOutgoingCommand createCommand()
{
return new GitOutgoingCommand(handler, new GitContext(outgoingDirectory, outgoingRepository, new GitRepositoryConfigStoreProvider(new InMemoryConfigurationStoreFactory())),
outgoingRepository);
return new GitOutgoingCommand(handler, new GitContext(outgoingDirectory, outgoingRepository, new GitRepositoryConfigStoreProvider(new InMemoryConfigurationStoreFactory())));
}
}

View File

@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package sonia.scm.repository.spi;
//~--- non-JDK imports --------------------------------------------------------
@@ -89,7 +89,6 @@ public class GitPushCommandTest extends AbstractRemoteCommandTestBase
*/
private GitPushCommand createCommand()
{
return new GitPushCommand(handler, new GitContext(outgoingDirectory, null, null),
outgoingRepository);
return new GitPushCommand(handler, new GitContext(outgoingDirectory, outgoingRepository, null));
}
}