Skip to main content

Module endpoint

Module endpoint 

Source
Expand description

Resolve the LFS server endpoint for a repo.

Implements the priority chain documented in docs/api/server-discovery.md, plus the SSH/git URL → HTTPS rewriting upstream does so a git@github.com:foo/bar.git remote yields the expected https://github.com/foo/bar.git/info/lfs endpoint.

§Priority order

  1. GIT_LFS_URL environment variable (matches upstream’s escape hatch).
  2. lfs.url from git config — local → global → system → .lfsconfig.
  3. remote.<name>.lfsurl (same scopes as above).
  4. remote.<name>.url rewritten via derive_lfs_url.

<name> defaults to origin when the caller hasn’t passed a remote.

§SSH-style URLs

git lfs itself only speaks HTTP(S); for SSH remotes the protocol is still HTTPS, just inferred from the remote’s host/path. Upstream also supports the git-lfs-authenticate SSH command for handing back a token; that’s deferred (see NOTES.md).

Structs§

EndpointInfo
LFS endpoint resolution result with the optional SSH metadata upstream’s git lfs env displays alongside the HTTPS-equivalent endpoint URL.
SshInfo
SSH-shaped remote/endpoint URL parsed into the components git lfs env echoes back as SSH=<user_and_host>:<path>.

Enums§

EndpointError

Functions§

derive_lfs_url
Convert a clone URL into the matching LFS endpoint URL.
endpoint_for_remote
Resolve the LFS endpoint URL for cwd + remote. Pass None for the default (origin, with a “single remote” fallback when origin doesn’t exist and exactly one other remote does).
looks_like_url
Quick syntactic check: does s look like one of the URL forms derive_lfs_url recognizes? Used to decide whether to treat a “remote name” argument as a literal URL.
parse_ssh_url
Extract the SSH metadata from a remote URL — the <user_and_host> and <path> pieces git lfs env echoes back as SSH=<user_and_host>:<path>. Returns None for URLs that don’t look SSH-shaped (HTTP(S), git://, file://, plain paths).
resolve_endpoint
Like endpoint_for_remote, but also returns the SSH metadata when the underlying URL was SSH-shaped. Used by git lfs env to render the SSH=<user_and_host>:<path> line alongside the HTTPS-equivalent endpoint.