diff options
author | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-05 10:53:12 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2018-03-05 10:53:28 +0900 |
commit | 60b43c03e218a7c94257105820b790e8dbc0ab6f (patch) | |
tree | 1a20e432b793eba2c97357d3603d100f1ff48a22 | |
parent | 28167853c120540db97a5c092646d0ed3316e1e8 (diff) | |
download | jgit-60b43c03e218a7c94257105820b790e8dbc0ab6f.tar.gz jgit-60b43c03e218a7c94257105820b790e8dbc0ab6f.zip |
Add ConfigConstants.CONFIG_SECTION_LFS
DirCacheCheckout has a warning about non-localised string "lfs". Other
classes use org.eclipse.jgit.lfs.lib.Constants but that is not visible
to DirCacheCheckout.
Add a new constant in ConfigConstants and use that in DirCacheCheckout.
Replace existing uses of org.eclipse.jgit.lfs.lib.Constants.LFS with
the new constant, except where it is referring to the folder name.
Change-Id: I0f21b951babff9a2e579d68c4de0c62ee4bc23d4
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
6 files changed, 27 insertions, 15 deletions
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 67c8bd267c..fb6225b1c1 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 @@ -53,7 +53,6 @@ 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; @@ -81,11 +80,13 @@ public class CheckoutTest extends LfsServerTest { .create(tmp.resolve(".git").toFile()); db.create(); StoredConfig cfg = db.getConfig(); - cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION, Constants.LFS, + cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION, + ConfigConstants.CONFIG_SECTION_LFS, ConfigConstants.CONFIG_KEY_USEJGITBUILTIN, true); - cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION, Constants.LFS, + cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION, + ConfigConstants.CONFIG_SECTION_LFS, ConfigConstants.CONFIG_KEY_REQUIRED, false); - cfg.setString(Constants.LFS, null, "url", + cfg.setString(ConfigConstants.CONFIG_SECTION_LFS, null, "url", server.getURI().toString() + "/lfs"); cfg.save(); @@ -122,7 +123,8 @@ public class CheckoutTest extends LfsServerTest { @Test(expected = JGitInternalException.class) public void testUnknownContentRequired() throws Exception { StoredConfig cfg = tdb.getRepository().getConfig(); - cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION, Constants.LFS, + cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION, + ConfigConstants.CONFIG_SECTION_LFS, ConfigConstants.CONFIG_KEY_REQUIRED, true); cfg.save(); diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java index e1b9e34ed5..d65e4e9993 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java @@ -49,7 +49,6 @@ import java.io.PrintStream; import org.eclipse.jgit.annotations.Nullable; import org.eclipse.jgit.attributes.Attribute; import org.eclipse.jgit.hooks.PrePushHook; -import org.eclipse.jgit.lfs.lib.Constants; import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.ObjectLoader; import org.eclipse.jgit.lib.Repository; @@ -118,7 +117,8 @@ public class BuiltinLFS extends LfsFactory { return false; } return db.getConfig().getBoolean(ConfigConstants.CONFIG_FILTER_SECTION, - Constants.LFS, ConfigConstants.CONFIG_KEY_USEJGITBUILTIN, + ConfigConstants.CONFIG_SECTION_LFS, + ConfigConstants.CONFIG_KEY_USEJGITBUILTIN, false); } @@ -134,7 +134,8 @@ public class BuiltinLFS extends LfsFactory { if (attribute == null) { return false; } - return isEnabled(db) && Constants.LFS.equals(attribute.getValue()); + return isEnabled(db) && ConfigConstants.CONFIG_SECTION_LFS + .equals(attribute.getValue()); } } diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/InstallLfsCommand.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/InstallLfsCommand.java index f9e863c0fc..b204d0c156 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/InstallLfsCommand.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/InstallLfsCommand.java @@ -48,7 +48,6 @@ import java.util.concurrent.Callable; import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.lfs.internal.LfsText; -import org.eclipse.jgit.lfs.lib.Constants; import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.StoredConfig; @@ -81,9 +80,11 @@ public class InstallLfsCommand implements Callable<Void>{ cfg = repository.getConfig(); } - cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION, Constants.LFS, + cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION, + ConfigConstants.CONFIG_SECTION_LFS, ConfigConstants.CONFIG_KEY_USEJGITBUILTIN, true); - cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION, Constants.LFS, + cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION, + ConfigConstants.CONFIG_SECTION_LFS, ConfigConstants.CONFIG_KEY_REQUIRED, true); cfg.save(); diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java index 3196e0730e..5d8268b73e 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java @@ -61,7 +61,6 @@ import org.eclipse.jgit.annotations.NonNull; import org.eclipse.jgit.lfs.LfsPointer; import org.eclipse.jgit.lfs.Protocol; import org.eclipse.jgit.lfs.errors.LfsConfigInvalidException; -import org.eclipse.jgit.lfs.lib.Constants; import org.eclipse.jgit.lib.ConfigConstants; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.StoredConfig; @@ -131,12 +130,14 @@ public class LfsConnectionFactory { Map<String, String> additionalHeaders) throws LfsConfigInvalidException { StoredConfig config = db.getConfig(); - String lfsUrl = config.getString(Constants.LFS, null, + String lfsUrl = config.getString(ConfigConstants.CONFIG_SECTION_LFS, + null, ConfigConstants.CONFIG_KEY_URL); if (lfsUrl == null) { String remoteUrl = null; for (String remote : db.getRemoteNames()) { - lfsUrl = config.getString(Constants.LFS, remote, + lfsUrl = config.getString(ConfigConstants.CONFIG_SECTION_LFS, + remote, ConfigConstants.CONFIG_KEY_URL); // This could be done better (more precise logic), but according // to https://github.com/git-lfs/git-lfs/issues/1759 git-lfs diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java index 5c85afd8df..0b03eb1521 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java @@ -1541,7 +1541,8 @@ public class DirCacheCheckout { CheckoutMetadata checkoutMetadata, ObjectLoader ol, OutputStream channel) throws MissingObjectException, IOException { boolean isMandatory = repo.getConfig().getBoolean( - ConfigConstants.CONFIG_FILTER_SECTION, "lfs", + ConfigConstants.CONFIG_FILTER_SECTION, + ConfigConstants.CONFIG_SECTION_LFS, ConfigConstants.CONFIG_KEY_REQUIRED, false); FilterCommand command = null; try { diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java index 9091629e0c..5a790350b1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java @@ -426,4 +426,10 @@ public class ConfigConstants { * @since 4.11 */ public static final String CONFIG_KEY_REQUIRED = "required"; + + /** + * The "lfs" section + * @since 4.11 + */ + public static final String CONFIG_SECTION_LFS = "lfs"; } |