Class LfsFactory

  • Direct Known Subclasses:
    BuiltinLFS

    public class LfsFactory
    extends java.lang.Object
    Represents an optionally present LFS support implementation
    Since:
    4.11
    • Constructor Detail

      • LfsFactory

        protected LfsFactory()
        Constructor
    • Method Detail

      • getInstance

        public static LfsFactory getInstance()
        Returns:
        the current LFS implementation
      • setInstance

        public static void setInstance​(LfsFactory instance)
        Parameters:
        instance - register a LfsFactory instance as the LfsFactory implementation to use.
      • isAvailable

        public boolean isAvailable()
        Returns:
        whether LFS support is available
      • applyCleanFilter

        public LfsFactory.LfsInputStream applyCleanFilter​(Repository db,
                                                          java.io.InputStream input,
                                                          long length,
                                                          Attribute attribute)
                                                   throws java.io.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 repository
        input - the original input
        length - the expected input stream length
        attribute - 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:
        java.io.IOException - in case of an error
      • applySmudgeFilter

        public ObjectLoader applySmudgeFilter​(Repository db,
                                              ObjectLoader loader,
                                              Attribute attribute)
                                       throws java.io.IOException
        Apply smudge filtering to a given loader, potentially redirecting it to a LFS blob which is downloaded on demand.
        Parameters:
        db - the repository
        loader - the loader for the blob
        attribute - 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:
        java.io.IOException
      • getPrePushHook

        @Nullable
        public PrePushHook getPrePushHook​(Repository repo,
                                          java.io.PrintStream outputStream)
        Retrieve a pre-push hook to be applied using the default error stream.
        Parameters:
        repo - the Repository the hook is applied to.
        outputStream -
        Returns:
        a PrePushHook implementation or null
      • getPrePushHook

        @Nullable
        public PrePushHook getPrePushHook​(Repository repo,
                                          java.io.PrintStream outputStream,
                                          java.io.PrintStream errorStream)
        Retrieve a pre-push hook to be applied.
        Parameters:
        repo - the Repository the hook is applied to.
        outputStream -
        errorStream -
        Returns:
        a PrePushHook implementation or null
        Since:
        5.6
      • isEnabled

        public boolean isEnabled​(Repository db)
        Parameters:
        db - the repository to check
        Returns:
        whether LFS is enabled for the given repository locally or globally.
      • getAttributesForPath

        public static Attributes getAttributesForPath​(Repository db,
                                                      java.lang.String path)
                                               throws java.io.IOException
        Parameters:
        db - the repository
        path - the path to find attributes for
        Returns:
        the Attributes for the given path.
        Throws:
        java.io.IOException - in case of an error
      • getAttributesForPath

        public static Attributes getAttributesForPath​(Repository db,
                                                      java.lang.String path,
                                                      RevCommit commit)
                                               throws java.io.IOException
        Get attributes for given path and commit
        Parameters:
        db - the repository
        path - the path to find attributes for
        commit - the commit to inspect.
        Returns:
        the Attributes for the given path.
        Throws:
        java.io.IOException - in case of an error