mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-12-22 00:09:47 +01:00
Git import with lfs support (#2133)
This adds the possibility to load files managed by lfs to the repository import of git repositories. Co-authored-by: Konstantin Schaper <konstantin.schaper@cloudogu.com>
This commit is contained in:
@@ -40,6 +40,7 @@ import java.io.IOException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -49,6 +50,9 @@ import static org.junit.Assert.assertNotNull;
|
||||
public class GitIncomingCommandTest
|
||||
extends AbstractRemoteCommandTestBase {
|
||||
|
||||
private final LfsLoader lfsLoader = mock(LfsLoader.class);
|
||||
private final PullHttpConnectionProvider pullHttpConnectionProvider = mock(PullHttpConnectionProvider.class);
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -99,7 +103,9 @@ public class GitIncomingCommandTest
|
||||
GitPullCommand pull = new GitPullCommand(
|
||||
handler,
|
||||
context,
|
||||
postReceiveRepositoryHookEventFactory);
|
||||
postReceiveRepositoryHookEventFactory,
|
||||
lfsLoader,
|
||||
pullHttpConnectionProvider);
|
||||
PullCommandRequest req = new PullCommandRequest();
|
||||
req.setRemoteRepository(outgoingRepository);
|
||||
pull.pull(req);
|
||||
|
||||
@@ -858,18 +858,17 @@ public class GitMirrorCommandTest extends AbstractGitCommandTestBase {
|
||||
// one revision is missing here ("fcd0ef1831e4002ac43ea539f4094334c79ea9ec"), because this is iterated twice, what is hard to test
|
||||
}).forEach(expectedRevision ->
|
||||
verify(lfsLoader)
|
||||
.inspectTree(eq(ObjectId.fromString(expectedRevision)), any(), any(), any(), any(), eq(repository)));
|
||||
.inspectTree(eq(ObjectId.fromString(expectedRevision)), any(), any(), any(), eq(repository), any(), any()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldMarkMirrorAsFailedIfLfsFileFailes() {
|
||||
public void shouldMarkMirrorAsFailedIfLfsFileFails() {
|
||||
doAnswer(invocation -> {
|
||||
invocation.getArgument(4, MirrorCommandResult.LfsUpdateResult.class).increaseFailureCount();
|
||||
invocation.getArgument(3, MirrorCommandResult.LfsUpdateResult.class).increaseFailureCount();
|
||||
return null;
|
||||
})
|
||||
.when(lfsLoader)
|
||||
.inspectTree(eq(ObjectId.fromString("a8495c0335a13e6e432df90b3727fa91943189a7")), any(), any(), any(), any(), eq(repository));
|
||||
|
||||
.inspectTree(eq(ObjectId.fromString("a8495c0335a13e6e432df90b3727fa91943189a7")), any(), any(), any(), eq(repository), any(), any());
|
||||
|
||||
MirrorCommandResult mirrorCommandResult = callMirrorCommand();
|
||||
|
||||
@@ -881,7 +880,7 @@ public class GitMirrorCommandTest extends AbstractGitCommandTestBase {
|
||||
callMirrorCommand(repositoryDirectory.getAbsolutePath(), c -> c.setIgnoreLfs(true));
|
||||
|
||||
verify(lfsLoader, never())
|
||||
.inspectTree(any(), any(), any(), any(), any(), any());
|
||||
.inspectTree(any(), any(), any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
public static class DefaultBranchSelectorTest {
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import sonia.scm.repository.GitConfig;
|
||||
@@ -49,6 +50,11 @@ public class GitModificationsCommandTest extends AbstractRemoteCommandTestBase {
|
||||
private GitModificationsCommand incomingModificationsCommand;
|
||||
private GitModificationsCommand outgoingModificationsCommand;
|
||||
|
||||
@Mock
|
||||
private LfsLoader lfsLoader;
|
||||
@Mock
|
||||
private PullHttpConnectionProvider pullHttpConnectionProvider;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
incomingModificationsCommand = new GitModificationsCommand(Mockito.spy(new GitContext(incomingDirectory, incomingRepository, null, new GitConfig())));
|
||||
@@ -171,7 +177,9 @@ public class GitModificationsCommandTest extends AbstractRemoteCommandTestBase {
|
||||
GitPullCommand pullCommand = new GitPullCommand(
|
||||
handler,
|
||||
context,
|
||||
postReceiveRepositoryHookEventFactory);
|
||||
postReceiveRepositoryHookEventFactory,
|
||||
lfsLoader,
|
||||
pullHttpConnectionProvider);
|
||||
PullCommandRequest pullRequest = new PullCommandRequest();
|
||||
pullRequest.setRemoteRepository(incomingRepository);
|
||||
pullCommand.pull(pullRequest);
|
||||
|
||||
Reference in New Issue
Block a user