module documentation
Bundle URI support for faster clones and fetches.
This module implements support for Git bundle URIs as specified in https://git-scm.com/docs/bundle-uri
Bundle URIs allow Git servers to advertise locations where clients can download pre-computed bundles to speed up clones and fetches.
| Class | |
Represents a bundle list as defined in the bundle URI specification. |
| Class | |
Represents a single bundle in a bundle list. |
| Exception | |
Error related to bundle URI operations. |
| Function | fetch |
Fetch content from a bundle URI. |
| Function | parse |
Parse a bundle list from Git config format. |
| Function | parse |
Parse bundle URI advertisement from protocol v2 capabilities. |
| Constant | CAPABILITY |
Undocumented |
| Function | _filter |
Filter bundle entries based on object filter specification. |
| Function | _is |
Check if a URI is absolute (has a scheme). |
| Function | _is |
Check if data starts with a bundle file header. |
| Function | _resolve |
Resolve a relative URI against a base URI. |
def fetch_bundle_uri(uri:
str, progress: Callable[ [ bytes], None] | None = None, timeout: float | None = None) -> tuple[ Bundle | None, BundleList | None]:
¶
Fetch content from a bundle URI.
The URI may point to either a bundle file or a bundle list.
| Parameters | |
uri:str | The URI to fetch from (HTTP/HTTPS) |
progress:Callable[ | Optional callback for progress reporting |
timeout:float | None | Optional timeout for the HTTP request |
| Returns | |
tuple[ | A tuple of (Bundle, None) if the URI points to a bundle file, or (None, BundleList) if the URI points to a bundle list. |
| Raises | |
BundleURIError | If the fetch fails or the content is invalid |
Parse a bundle list from Git config format.
| Parameters | |
data:bytes | The raw bundle list data in Git config format |
basestr | None | Base URI for resolving relative URIs in the bundle list |
| Returns | |
BundleList | A BundleList object representing the parsed bundle list |
| Raises | |
BundleURIError | If the bundle list format is invalid |
def parse_bundle_uri_advertisement(capabilities:
list[ tuple[ bytes, bytes | None]]) -> list[ tuple[ str, str | None]]:
¶
Parse bundle URI advertisement from protocol v2 capabilities.
Extracts bundle-uri related capabilities from a Git protocol v2 capability advertisement. The server may advertise bundle URIs as part of its capabilities to allow clients to bootstrap clones.
| Parameters | |
capabilities:list[ | List of (key, value) capability pairs from the server |
| Returns | |
list[ | List of (key, value) pairs where key starts with "bundle-uri". The key is the capability name (e.g., "bundle-uri") and value is the URI string or None if no value was provided. Returns an empty list if no bundle URI capabilities are advertised. |
def _filter_bundle_entries(entries:
list[ BundleListEntry], filter_spec: str | None) -> list[ BundleListEntry]:
¶
Filter bundle entries based on object filter specification.
| Parameters | |
entries:list[ | List of bundle entries to filter |
filterstr | None | Object filter to match (e.g., "blob:none"), or None for full clones |
| Returns | |
list[ | List of matching bundle entries |