diff options
author | Markus Duft <markus.duft@ssi-schaefer.com> | 2018-03-05 10:34:29 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2018-03-07 22:02:02 +0100 |
commit | 0f9ec9e406b903ab9be6a95e15a282da9a6c5512 (patch) | |
tree | 32ab0ee30f4e7a9ab971fe7bed20e015111e7d92 | |
parent | 9f689e90d42a6405054df1f98e43902c87595317 (diff) | |
download | jgit-0f9ec9e406b903ab9be6a95e15a282da9a6c5512.tar.gz jgit-0f9ec9e406b903ab9be6a95e15a282da9a6c5512.zip |
LFS: Adjust some API to make integration into tools (EGit,...) easier
Make the install command accessible without requiring reflection.
Expose the isEnabled(Repository) API to be able to check if calling the
install command is required for a repository.
Change-Id: I17e6eaefb6afda17fea8162cbf0cb86a20506753
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r-- | org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java | 8 | ||||
-rw-r--r-- | org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/InstallBuiltinLfsCommand.java (renamed from org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/InstallLfsCommand.java) | 7 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java | 34 |
3 files changed, 45 insertions, 4 deletions
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 d65e4e9993..415caa9859 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 @@ -112,7 +112,8 @@ public class BuiltinLFS extends LfsFactory { * the repository * @return whether LFS is requested for the given repo. */ - private boolean isEnabled(Repository db) { + @Override + public boolean isEnabled(Repository db) { if (db == null) { return false; } @@ -138,4 +139,9 @@ public class BuiltinLFS extends LfsFactory { .equals(attribute.getValue()); } + @Override + public LfsInstallCommand getInstallCommand() { + return new InstallBuiltinLfsCommand(); + } + } diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/InstallLfsCommand.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/InstallBuiltinLfsCommand.java index b204d0c156..028b19b2ab 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/InstallLfsCommand.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/InstallBuiltinLfsCommand.java @@ -44,7 +44,6 @@ package org.eclipse.jgit.lfs; import java.io.IOException; import java.text.MessageFormat; -import java.util.concurrent.Callable; import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.lfs.internal.LfsText; @@ -53,6 +52,7 @@ import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.storage.file.FileBasedConfig; import org.eclipse.jgit.util.FS; +import org.eclipse.jgit.util.LfsFactory.LfsInstallCommand; import org.eclipse.jgit.util.SystemReader; /** @@ -61,7 +61,7 @@ import org.eclipse.jgit.util.SystemReader; * * @since 4.11 */ -public class InstallLfsCommand implements Callable<Void>{ +public class InstallBuiltinLfsCommand implements LfsInstallCommand { private static final String[] ARGS_USER = new String[] { "lfs", "install" }; //$NON-NLS-1$//$NON-NLS-2$ @@ -110,7 +110,8 @@ public class InstallLfsCommand implements Callable<Void>{ * configuration * @return this command */ - public InstallLfsCommand setRepository(Repository repo) { + @Override + public LfsInstallCommand setRepository(Repository repo) { this.repository = repo; return this; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java index 9200916495..6d60ef3f4d 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/LfsFactory.java @@ -46,6 +46,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.text.MessageFormat; +import java.util.concurrent.Callable; import org.eclipse.jgit.annotations.Nullable; import org.eclipse.jgit.attributes.Attribute; @@ -157,6 +158,26 @@ public class LfsFactory { } /** + * Retrieve an {@link LfsInstallCommand} which can be used to enable LFS + * support (if available) either per repository or for the user. + * + * @return a command to install LFS support. + */ + public @Nullable LfsInstallCommand getInstallCommand() { + return null; + } + + /** + * @param db + * the repository to check + * @return whether LFS is enabled for the given repository locally or + * globally. + */ + public boolean isEnabled(Repository db) { + return false; + } + + /** * @param db * the repository * @param path @@ -281,4 +302,17 @@ public class LfsFactory { } } + /** + * A command to enable LFS. Optionally set a {@link Repository} to enable + * locally on the repository only. + */ + public interface LfsInstallCommand extends Callable<Void> { + /** + * @param repo + * the repository to enable support for. + * @return The {@link LfsInstallCommand} for chaining. + */ + public LfsInstallCommand setRepository(Repository repo); + } + } |