mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
Remove unnecessary interface
This commit is contained in:
@@ -160,6 +160,10 @@ public class HgCommandContext implements Closeable
|
||||
return handler.getConfig();
|
||||
}
|
||||
|
||||
public sonia.scm.repository.Repository getScmRepository() {
|
||||
return scmRepository;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
|
||||
@@ -15,27 +15,19 @@ import java.util.function.BiConsumer;
|
||||
|
||||
public class SimpleHgWorkdirFactory extends SimpleWorkdirFactory<Repository, HgCommandContext> implements HgWorkdirFactory {
|
||||
|
||||
private final Provider<HgRepositoryEnvironmentBuilder> hgRepositoryEnvironmentBuilder;
|
||||
|
||||
@Inject
|
||||
public SimpleHgWorkdirFactory(Provider<HgRepositoryEnvironmentBuilder> hgRepositoryEnvironmentBuilder) {
|
||||
super(new HgCloneProvider(hgRepositoryEnvironmentBuilder));
|
||||
this.hgRepositoryEnvironmentBuilder = hgRepositoryEnvironmentBuilder;
|
||||
}
|
||||
|
||||
private static class HgCloneProvider implements CloneProvider<Repository, HgCommandContext> {
|
||||
|
||||
private final Provider<HgRepositoryEnvironmentBuilder> hgRepositoryEnvironmentBuilder;
|
||||
|
||||
private HgCloneProvider(Provider<HgRepositoryEnvironmentBuilder> hgRepositoryEnvironmentBuilder) {
|
||||
this.hgRepositoryEnvironmentBuilder = hgRepositoryEnvironmentBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ParentAndClone<Repository> cloneRepository(HgCommandContext context, File target) throws IOException {
|
||||
BiConsumer<sonia.scm.repository.Repository, Map<String, String>> repositoryMapBiConsumer =
|
||||
(repository, environment) -> hgRepositoryEnvironmentBuilder.get().buildFor(repository, null, environment);
|
||||
Repository centralRepository = context.openWithSpecialEnvironment(repositoryMapBiConsumer);
|
||||
CloneCommand.on(centralRepository).execute(target.getAbsolutePath());
|
||||
return new ParentAndClone<>(centralRepository, Repository.open(target));
|
||||
}
|
||||
@Override
|
||||
public ParentAndClone<Repository> cloneRepository(HgCommandContext context, File target) throws IOException {
|
||||
BiConsumer<sonia.scm.repository.Repository, Map<String, String>> repositoryMapBiConsumer =
|
||||
(repository, environment) -> hgRepositoryEnvironmentBuilder.get().buildFor(repository, null, environment);
|
||||
Repository centralRepository = context.openWithSpecialEnvironment(repositoryMapBiConsumer);
|
||||
CloneCommand.on(centralRepository).execute(target.getAbsolutePath());
|
||||
return new ParentAndClone<>(centralRepository, Repository.open(target));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,8 +36,8 @@ public class SimpleHgWorkdirFactory extends SimpleWorkdirFactory<Repository, HgC
|
||||
}
|
||||
|
||||
@Override
|
||||
protected sonia.scm.repository.Repository getRepository(HgCommandContext context) {
|
||||
return null;
|
||||
protected sonia.scm.repository.Repository getScmRepository(HgCommandContext context) {
|
||||
return context.getScmRepository();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.aragost.javahg.commands.PullCommand;
|
||||
import com.google.inject.util.Providers;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.Test;
|
||||
@@ -19,7 +20,12 @@ public class HgBranchCommandTest extends AbstractHgCommandTestBase {
|
||||
HgRepositoryEnvironmentBuilder hgRepositoryEnvironmentBuilder =
|
||||
new HgRepositoryEnvironmentBuilder(handler, HgTestUtil.createHookManager());
|
||||
|
||||
SimpleHgWorkdirFactory workdirFactory = new SimpleHgWorkdirFactory(Providers.of(hgRepositoryEnvironmentBuilder));
|
||||
SimpleHgWorkdirFactory workdirFactory = new SimpleHgWorkdirFactory(Providers.of(hgRepositoryEnvironmentBuilder)) {
|
||||
@Override
|
||||
public void configure(PullCommand pullCommand) {
|
||||
// we do not want to configure http hooks in this unit test
|
||||
}
|
||||
};
|
||||
|
||||
BranchRequest branchRequest = new BranchRequest();
|
||||
branchRequest.setNewBranch("new_branch");
|
||||
|
||||
Reference in New Issue
Block a user