From c0103bc59d5b4a539f01bc9c98610ab3f11be114 Mon Sep 17 00:00:00 2001 From: Markus Duft Date: Tue, 5 Dec 2017 11:16:30 +0100 Subject: LFS: Enable LFS support for the CLI, better error handling Enable LFS support for the CLI by registering the according filters. Errors during filter creation must be propagated up the call stack, as a failure to create a filter should be treated as fatal if the filter is required. Change-Id: I3833757839bdda97cd01b6c21c1613d199e2692d Signed-off-by: Markus Duft --- .../eclipse/jgit/lfs/server/fs/CheckoutTest.java | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'org.eclipse.jgit.lfs.server.test/tst') diff --git a/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/CheckoutTest.java b/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/CheckoutTest.java index df43ccf41b..67c8bd267c 100644 --- a/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/CheckoutTest.java +++ b/org.eclipse.jgit.lfs.server.test/tst/org/eclipse/jgit/lfs/server/fs/CheckoutTest.java @@ -49,10 +49,13 @@ import java.nio.file.Files; import java.nio.file.Path; import org.eclipse.jgit.api.Git; +import org.eclipse.jgit.api.errors.JGitInternalException; import org.eclipse.jgit.junit.JGitTestUtil; import org.eclipse.jgit.junit.TestRepository; import org.eclipse.jgit.lfs.BuiltinLFS; +import org.eclipse.jgit.lfs.lib.Constants; import org.eclipse.jgit.lfs.lib.LongObjectId; +import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.storage.file.FileRepositoryBuilder; @@ -78,8 +81,12 @@ public class CheckoutTest extends LfsServerTest { .create(tmp.resolve(".git").toFile()); db.create(); StoredConfig cfg = db.getConfig(); - cfg.setString("filter", "lfs", "usejgitbuiltin", "true"); - cfg.setString("lfs", null, "url", server.getURI().toString() + "/lfs"); + cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION, Constants.LFS, + ConfigConstants.CONFIG_KEY_USEJGITBUILTIN, true); + cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION, Constants.LFS, + ConfigConstants.CONFIG_KEY_REQUIRED, false); + cfg.setString(Constants.LFS, null, "url", + server.getURI().toString() + "/lfs"); cfg.save(); tdb = new TestRepository<>(db); @@ -112,6 +119,17 @@ public class CheckoutTest extends LfsServerTest { server.getRequests().toString()); } + @Test(expected = JGitInternalException.class) + public void testUnknownContentRequired() throws Exception { + StoredConfig cfg = tdb.getRepository().getConfig(); + cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION, Constants.LFS, + ConfigConstants.CONFIG_KEY_REQUIRED, true); + cfg.save(); + + // must throw + git.checkout().setName("test").call(); + } + @Test public void testKnownContent() throws Exception { putContent( -- cgit v1.2.3