Package org.eclipse.jgit.util
Class LfsFactory
java.lang.Object
org.eclipse.jgit.util.LfsFactory
- Direct Known Subclasses:
BuiltinLFS
Represents an optionally present LFS support implementation
- Since:
- 4.11
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classEncapsulate a potentially exchangedInputStreamalong with the expected stream content length.static interfaceA command to enable LFS. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyCleanFilter(Repository db, InputStream input, long length, Attribute attribute) Apply clean filtering to the given stream, writing the file content to the LFS storage if required and returning a stream to the LFS pointer instead.applySmudgeFilter(Repository db, ObjectLoader loader, Attribute attribute) Apply smudge filtering to a given loader, potentially redirecting it to a LFS blob which is downloaded on demand.static AttributesgetAttributesForPath(Repository db, String path) static AttributesgetAttributesForPath(Repository db, String path, RevCommit commit) Get attributes for given path and commitRetrieve anLfsFactory.LfsInstallCommandwhich can be used to enable LFS support (if available) either per repository or for the user.static LfsFactorygetPrePushHook(Repository repo, PrintStream outputStream) Retrieve a pre-push hook to be applied using the default error stream.getPrePushHook(Repository repo, PrintStream outputStream, PrintStream errorStream) Retrieve a pre-push hook to be applied.booleanbooleanisEnabled(Repository db) static voidsetInstance(LfsFactory instance)
-
Field Details
-
instance
-
-
Constructor Details
-
LfsFactory
protected LfsFactory()Constructor
-
-
Method Details
-
getInstance
- Returns:
- the current LFS implementation
-
setInstance
- Parameters:
instance- register aLfsFactoryinstance as theLfsFactoryimplementation to use.
-
isAvailable
public boolean isAvailable()- Returns:
- whether LFS support is available
-
applyCleanFilter
public LfsFactory.LfsInputStream applyCleanFilter(Repository db, InputStream input, long length, Attribute attribute) throws IOException Apply clean filtering to the given stream, writing the file content to the LFS storage if required and returning a stream to the LFS pointer instead.- Parameters:
db- the repositoryinput- the original inputlength- the expected input stream lengthattribute- the attribute used to check for LFS enablement (i.e. "merge", "diff", "filter" from .gitattributes).- Returns:
- a stream to the content that should be written to the object store along with the expected length of the stream. the original stream is not applicable.
- Throws:
IOException- in case of an error
-
applySmudgeFilter
public ObjectLoader applySmudgeFilter(Repository db, ObjectLoader loader, Attribute attribute) throws IOException Apply smudge filtering to a given loader, potentially redirecting it to a LFS blob which is downloaded on demand.- Parameters:
db- the repositoryloader- the loader for the blobattribute- the attribute used to check for LFS enablement (i.e. "merge", "diff", "filter" from .gitattributes).- Returns:
- a loader for the actual data of a blob, or the original loader in case LFS is not applicable.
- Throws:
IOException
-
getPrePushHook
Retrieve a pre-push hook to be applied using the default error stream.- Parameters:
repo- theRepositorythe hook is applied to.outputStream-- Returns:
- a
PrePushHookimplementation ornull
-
getPrePushHook
@Nullable public PrePushHook getPrePushHook(Repository repo, PrintStream outputStream, PrintStream errorStream) Retrieve a pre-push hook to be applied.- Parameters:
repo- theRepositorythe hook is applied to.outputStream-errorStream-- Returns:
- a
PrePushHookimplementation ornull - Since:
- 5.6
-
getInstallCommand
Retrieve anLfsFactory.LfsInstallCommandwhich can be used to enable LFS support (if available) either per repository or for the user.- Returns:
- a command to install LFS support.
-
isEnabled
- Parameters:
db- the repository to check- Returns:
- whether LFS is enabled for the given repository locally or globally.
-
getAttributesForPath
- Parameters:
db- the repositorypath- the path to find attributes for- Returns:
- the
Attributesfor the given path. - Throws:
IOException- in case of an error
-
getAttributesForPath
public static Attributes getAttributesForPath(Repository db, String path, RevCommit commit) throws IOException Get attributes for given path and commit- Parameters:
db- the repositorypath- the path to find attributes forcommit- the commit to inspect.- Returns:
- the
Attributesfor the given path. - Throws:
IOException- in case of an error
-