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>
This commit is contained in:
parent
28167853c1
commit
60b43c03e2
|
@ -53,7 +53,6 @@
|
||||||
import org.eclipse.jgit.junit.JGitTestUtil;
|
import org.eclipse.jgit.junit.JGitTestUtil;
|
||||||
import org.eclipse.jgit.junit.TestRepository;
|
import org.eclipse.jgit.junit.TestRepository;
|
||||||
import org.eclipse.jgit.lfs.BuiltinLFS;
|
import org.eclipse.jgit.lfs.BuiltinLFS;
|
||||||
import org.eclipse.jgit.lfs.lib.Constants;
|
|
||||||
import org.eclipse.jgit.lfs.lib.LongObjectId;
|
import org.eclipse.jgit.lfs.lib.LongObjectId;
|
||||||
import org.eclipse.jgit.lib.ConfigConstants;
|
import org.eclipse.jgit.lib.ConfigConstants;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
|
@ -81,11 +80,13 @@ public void setup() throws Exception {
|
||||||
.create(tmp.resolve(".git").toFile());
|
.create(tmp.resolve(".git").toFile());
|
||||||
db.create();
|
db.create();
|
||||||
StoredConfig cfg = db.getConfig();
|
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);
|
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);
|
ConfigConstants.CONFIG_KEY_REQUIRED, false);
|
||||||
cfg.setString(Constants.LFS, null, "url",
|
cfg.setString(ConfigConstants.CONFIG_SECTION_LFS, null, "url",
|
||||||
server.getURI().toString() + "/lfs");
|
server.getURI().toString() + "/lfs");
|
||||||
cfg.save();
|
cfg.save();
|
||||||
|
|
||||||
|
@ -122,7 +123,8 @@ public void testUnknownContent() throws Exception {
|
||||||
@Test(expected = JGitInternalException.class)
|
@Test(expected = JGitInternalException.class)
|
||||||
public void testUnknownContentRequired() throws Exception {
|
public void testUnknownContentRequired() throws Exception {
|
||||||
StoredConfig cfg = tdb.getRepository().getConfig();
|
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);
|
ConfigConstants.CONFIG_KEY_REQUIRED, true);
|
||||||
cfg.save();
|
cfg.save();
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,6 @@
|
||||||
import org.eclipse.jgit.annotations.Nullable;
|
import org.eclipse.jgit.annotations.Nullable;
|
||||||
import org.eclipse.jgit.attributes.Attribute;
|
import org.eclipse.jgit.attributes.Attribute;
|
||||||
import org.eclipse.jgit.hooks.PrePushHook;
|
import org.eclipse.jgit.hooks.PrePushHook;
|
||||||
import org.eclipse.jgit.lfs.lib.Constants;
|
|
||||||
import org.eclipse.jgit.lib.ConfigConstants;
|
import org.eclipse.jgit.lib.ConfigConstants;
|
||||||
import org.eclipse.jgit.lib.ObjectLoader;
|
import org.eclipse.jgit.lib.ObjectLoader;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
|
@ -118,7 +117,8 @@ private boolean isEnabled(Repository db) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return db.getConfig().getBoolean(ConfigConstants.CONFIG_FILTER_SECTION,
|
return db.getConfig().getBoolean(ConfigConstants.CONFIG_FILTER_SECTION,
|
||||||
Constants.LFS, ConfigConstants.CONFIG_KEY_USEJGITBUILTIN,
|
ConfigConstants.CONFIG_SECTION_LFS,
|
||||||
|
ConfigConstants.CONFIG_KEY_USEJGITBUILTIN,
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,8 @@ private boolean isEnabled(Repository db, Attribute attribute) {
|
||||||
if (attribute == null) {
|
if (attribute == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return isEnabled(db) && Constants.LFS.equals(attribute.getValue());
|
return isEnabled(db) && ConfigConstants.CONFIG_SECTION_LFS
|
||||||
|
.equals(attribute.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,6 @@
|
||||||
|
|
||||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||||
import org.eclipse.jgit.lfs.internal.LfsText;
|
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.ConfigConstants;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.eclipse.jgit.lib.StoredConfig;
|
import org.eclipse.jgit.lib.StoredConfig;
|
||||||
|
@ -81,9 +80,11 @@ public Void call() throws Exception {
|
||||||
cfg = repository.getConfig();
|
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);
|
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);
|
ConfigConstants.CONFIG_KEY_REQUIRED, true);
|
||||||
|
|
||||||
cfg.save();
|
cfg.save();
|
||||||
|
|
|
@ -61,7 +61,6 @@
|
||||||
import org.eclipse.jgit.lfs.LfsPointer;
|
import org.eclipse.jgit.lfs.LfsPointer;
|
||||||
import org.eclipse.jgit.lfs.Protocol;
|
import org.eclipse.jgit.lfs.Protocol;
|
||||||
import org.eclipse.jgit.lfs.errors.LfsConfigInvalidException;
|
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.ConfigConstants;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
import org.eclipse.jgit.lib.StoredConfig;
|
import org.eclipse.jgit.lib.StoredConfig;
|
||||||
|
@ -131,12 +130,14 @@ private static String getLfsUrl(Repository db, String purpose,
|
||||||
Map<String, String> additionalHeaders)
|
Map<String, String> additionalHeaders)
|
||||||
throws LfsConfigInvalidException {
|
throws LfsConfigInvalidException {
|
||||||
StoredConfig config = db.getConfig();
|
StoredConfig config = db.getConfig();
|
||||||
String lfsUrl = config.getString(Constants.LFS, null,
|
String lfsUrl = config.getString(ConfigConstants.CONFIG_SECTION_LFS,
|
||||||
|
null,
|
||||||
ConfigConstants.CONFIG_KEY_URL);
|
ConfigConstants.CONFIG_KEY_URL);
|
||||||
if (lfsUrl == null) {
|
if (lfsUrl == null) {
|
||||||
String remoteUrl = null;
|
String remoteUrl = null;
|
||||||
for (String remote : db.getRemoteNames()) {
|
for (String remote : db.getRemoteNames()) {
|
||||||
lfsUrl = config.getString(Constants.LFS, remote,
|
lfsUrl = config.getString(ConfigConstants.CONFIG_SECTION_LFS,
|
||||||
|
remote,
|
||||||
ConfigConstants.CONFIG_KEY_URL);
|
ConfigConstants.CONFIG_KEY_URL);
|
||||||
// This could be done better (more precise logic), but according
|
// This could be done better (more precise logic), but according
|
||||||
// to https://github.com/git-lfs/git-lfs/issues/1759 git-lfs
|
// to https://github.com/git-lfs/git-lfs/issues/1759 git-lfs
|
||||||
|
|
|
@ -1541,7 +1541,8 @@ private static void runBuiltinFilterCommand(Repository repo,
|
||||||
CheckoutMetadata checkoutMetadata, ObjectLoader ol,
|
CheckoutMetadata checkoutMetadata, ObjectLoader ol,
|
||||||
OutputStream channel) throws MissingObjectException, IOException {
|
OutputStream channel) throws MissingObjectException, IOException {
|
||||||
boolean isMandatory = repo.getConfig().getBoolean(
|
boolean isMandatory = repo.getConfig().getBoolean(
|
||||||
ConfigConstants.CONFIG_FILTER_SECTION, "lfs",
|
ConfigConstants.CONFIG_FILTER_SECTION,
|
||||||
|
ConfigConstants.CONFIG_SECTION_LFS,
|
||||||
ConfigConstants.CONFIG_KEY_REQUIRED, false);
|
ConfigConstants.CONFIG_KEY_REQUIRED, false);
|
||||||
FilterCommand command = null;
|
FilterCommand command = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -426,4 +426,10 @@ public class ConfigConstants {
|
||||||
* @since 4.11
|
* @since 4.11
|
||||||
*/
|
*/
|
||||||
public static final String CONFIG_KEY_REQUIRED = "required";
|
public static final String CONFIG_KEY_REQUIRED = "required";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The "lfs" section
|
||||||
|
* @since 4.11
|
||||||
|
*/
|
||||||
|
public static final String CONFIG_SECTION_LFS = "lfs";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue