Class LfsConnectionFactory


  • public class LfsConnectionFactory
    extends Object
    Provides means to get a valid LFS connection for a given repository.
    • Constructor Detail

      • LfsConnectionFactory

        public LfsConnectionFactory()
    • Method Detail

      • getLfsConnection

        public static HttpConnection getLfsConnection​(Repository db,
                                                      String method,
                                                      String purpose)
                                               throws IOException
        Determine URL of LFS server by looking into config parameters lfs.url, lfs.[remote].url or remote.[remote].url. The LFS server URL is computed from remote.[remote].url by appending "/info/lfs". In case there is no URL configured, a SSH remote URI can be used to auto-detect the LFS URI by using the remote "git-lfs-authenticate" command.
        Parameters:
        db - the repository to work with
        method - the method (GET,PUT,...) of the request this connection will be used for
        purpose - the action, e.g. Protocol.OPERATION_DOWNLOAD
        Returns:
        the connection for the lfs server. e.g. "https://github.com/github/git-lfs.git/info/lfs"
        Throws:
        IOException
      • getLfsContentConnection

        @NonNull
        public static HttpConnection getLfsContentConnection​(Repository repo,
                                                             Protocol.Action action,
                                                             String method)
                                                      throws IOException
        Create a connection for the specified Protocol.Action.
        Parameters:
        repo - the repo to fetch required configuration from
        action - the action for which to create a connection
        method - the target method (GET or PUT)
        Returns:
        a connection. output mode is not set.
        Throws:
        IOException - in case of any error.
      • toRequest

        public static Protocol.Request toRequest​(String operation,
                                                 LfsPointer... resources)
        Parameters:
        operation - the operation to perform, e.g. Protocol.OPERATION_DOWNLOAD
        resources - the LFS resources affected
        Returns:
        a request that can be serialized to JSON