Package org.eclipse.jgit.lfs.internal
Class LfsConnectionFactory
java.lang.Object
org.eclipse.jgit.lfs.internal.LfsConnectionFactory
Provides means to get a valid LFS connection for a given repository.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final String
private static final int
private static final Map<String,
LfsConnectionFactory.AuthCache> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
discoverLfsUrl
(Repository db, String purpose, Map<String, String> additionalHeaders, String remoteUrl) private static String
static HttpConnection
getLfsConnection
(Repository db, String method, String purpose) Determine URL of LFS server by looking into config parameters lfs.url, lfs.[remote].url or remote.[remote].url.static HttpConnection
getLfsContentConnection
(Repository repo, Protocol.Action action, String method) Create a connection for the specifiedProtocol.Action
.private static String
Get LFS Server URL.private static Protocol.ExpiringAction
getSshAuthentication
(Repository db, String purpose, String remoteUrl, URIish u) static Protocol.Request
toRequest
(String operation, LfsPointer... resources)
-
Field Details
-
SSH_AUTH_TIMEOUT_SECONDS
private static final int SSH_AUTH_TIMEOUT_SECONDS- See Also:
-
SCHEME_HTTPS
- See Also:
-
SCHEME_SSH
- See Also:
-
sshAuthCache
-
-
Constructor Details
-
LfsConnectionFactory
public LfsConnectionFactory()
-
-
Method Details
-
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 withmethod
- the method (GET,PUT,...) of the request this connection will be used forpurpose
- 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
-
getLfsUrl
private static String getLfsUrl(Repository db, String purpose, Map<String, String> additionalHeaders) throws IOExceptionGet LFS Server URL.- Parameters:
db
- the repository to work withpurpose
- the action, e.g. Protocol.OPERATION_DOWNLOADadditionalHeaders
- additional headers that can be used to connect to LFS server- Returns:
- the URL for the LFS server. e.g. "https://github.com/github/git-lfs.git/info/lfs"
- Throws:
IOException
- if the LFS config is invalid or cannot be accessed- See Also:
-
discoverLfsUrl
private static String discoverLfsUrl(Repository db, String purpose, Map<String, String> additionalHeaders, String remoteUrl) throws URISyntaxException, IOException, CommandFailedException -
getSshAuthentication
private static Protocol.ExpiringAction getSshAuthentication(Repository db, String purpose, String remoteUrl, URIish u) throws IOException, CommandFailedException - Throws:
IOException
CommandFailedException
-
getLfsContentConnection
@NonNull public static HttpConnection getLfsContentConnection(Repository repo, Protocol.Action action, String method) throws IOException Create a connection for the specifiedProtocol.Action
.- Parameters:
repo
- the repo to fetch required configuration fromaction
- the action for which to create a connectionmethod
- the target method (GET or PUT)- Returns:
- a connection. output mode is not set.
- Throws:
IOException
- in case of any error.
-
extractProjectName
-
toRequest
- Parameters:
operation
- the operation to perform, e.g. Protocol.OPERATION_DOWNLOADresources
- the LFS resources affected- Returns:
- a request that can be serialized to JSON
-