class documentation

Abstract base class for HTTP Git Clients.

This is agonistic of the actual HTTP implementation.

Subclasses should provide an implementation of the _http_request method.

Class Method from_parsedurl Create an AbstractHttpGitClient from a parsed URL.
Method __init__ Initialize AbstractHttpGitClient.
Method __repr__ Return string representation of this client.
Method fetch_pack Retrieve a pack from a git smart server.
Method get_refs Retrieve the current refs from a git smart server.
Method get_url Get the HTTP URL for a path.
Method send_pack Upload a pack to a remote repository.
Instance Variable dumb Undocumented
Instance Variable protocol_version Undocumented
Method _discover_references Undocumented
Method _get_url Undocumented
Method _http_request Perform HTTP request.
Method _smart_request Send a 'smart' HTTP request.
Instance Variable _base_url Undocumented
Instance Variable _password Undocumented
Instance Variable _report_status_parser Undocumented
Instance Variable _url_with_auth Undocumented
Instance Variable _username Undocumented

Inherited from GitClient:

Method archive Retrieve an archive of the specified tree.
Method clone Clone a repository.
Method close Close the client and release any resources.
Method fetch Fetch into a target repository.
Method fetch_with_bundle_uri Fetch into a target repository, using bundle URIs for bootstrap.
Static Method _should_send_pack Undocumented
Static Method _warn_filter_objects Undocumented
Method _handle_receive_pack_tail Handle the tail of a 'git-receive-pack' request.
Method _negotiate_receive_pack_capabilities Undocumented
Method _negotiate_upload_pack_capabilities Undocumented
Instance Variable _fetch_capabilities Undocumented
Instance Variable _report_activity Undocumented
Instance Variable _send_capabilities Undocumented
def from_parsedurl(cls, parsedurl: ParseResult, thin_packs: bool = True, report_activity: Callable[[int, str], None] | None = None, quiet: bool = False, include_tags: bool = False, dumb: bool = False, username: str | None = None, password: str | None = None, config: Config | None = None, pool_manager: urllib3.PoolManager | None = None) -> AbstractHttpGitClient:

Create an AbstractHttpGitClient from a parsed URL.

Parameters
parsedurl:ParseResultResult of urlparse()
thin_packs:boolWhether or not thin packs should be retrieved
report_activity:Callable[[int, str], None] | NoneOptional callback for reporting transport activity
quiet:boolWhether to suppress progress output
include_tags:boolWhether to include tags
dumb:boolWhether to use dumb HTTP transport
username:str | NoneOptional username for authentication
password:str | NoneOptional password for authentication
config:Config | NoneConfiguration object
pool_manager:urllib3.PoolManager | NoneOptional urllib3 PoolManager for HTTP(S) connections
Returns
AbstractHttpGitClientAn AbstractHttpGitClient instance
def __init__(self, base_url: str, dumb: bool = False, thin_packs: bool = True, report_activity: Callable[[int, str], None] | None = None, quiet: bool = False, include_tags: bool = False, username: str | None = None, password: str | None = None):

Initialize AbstractHttpGitClient.

def __repr__(self) -> str:

Return string representation of this client.

def fetch_pack(self, path: str | bytes, determine_wants: DetermineWantsFunc, graph_walker: GraphWalker, pack_data: Callable[[bytes], int], progress: Callable[[bytes], None] | None = None, depth: int | None = None, ref_prefix: Sequence[bytes] | None = None, filter_spec: bytes | None = None, protocol_version: int | None = None, shallow_since: str | None = None, shallow_exclude: list[str] | None = None) -> FetchPackResult:

Retrieve a pack from a git smart server.

Parameters
path:str | bytesPath to fetch from
determine_wants:DetermineWantsFuncCallback that returns list of commits to fetch
graph_walker:GraphWalkerObject with next() and ack().
pack_data:Callable[[bytes], int]Callback called for each bit of data in the pack
progress:Callable[[bytes], None] | NoneCallback for progress reports (strings)
depth:int | NoneDepth for request
ref_prefix:Sequence[bytes] | NoneList of prefixes of desired references, as a list of bytestrings. Filtering is done by the server if supported, and client side otherwise.
filter_spec:bytes | NoneA git-rev-list-style object filter spec, as bytestring. Only used if the server supports the Git protocol-v2 'filter' feature, and ignored otherwise.
protocol_version:int | NoneDesired Git protocol version. By default the highest mutually supported protocol version will be used.
shallow_since:str | NoneDeepen the history to include commits after this date
shallow_exclude:list[str] | NoneDeepen the history to exclude commits reachable from these refs
Returns
FetchPackResultFetchPackResult object
def get_refs(self, path: str | bytes, protocol_version: int | None = None, ref_prefix: Sequence[bytes] | None = None) -> LsRemoteResult:

Retrieve the current refs from a git smart server.

def get_url(self, path: str) -> str:

Get the HTTP URL for a path.

def send_pack(self, path: str | bytes, update_refs: Callable[[dict[Ref, ObjectID]], dict[Ref, ObjectID]], generate_pack_data: GeneratePackDataFunc, progress: Callable[[bytes], None] | None = None, push_options: Sequence[bytes] | None = None, atomic: bool = False) -> SendPackResult:

Upload a pack to a remote repository.

Parameters
path:str | bytesRepository path (as bytestring or string)
update_refs:Callable[[dict[Ref, ObjectID]], dict[Ref, ObjectID]]Function to determine changes to remote refs. Receives dict with existing remote refs, returns dict with changed refs (name -> sha, where sha=ZERO_SHA for deletions)
generate_pack_data:GeneratePackDataFuncFunction that can return a tuple with number of elements and pack data to upload.
progress:Callable[[bytes], None] | NoneOptional progress function
push_options:Sequence[bytes] | NoneOptional list of push options to send to the server
atomic:boolIf True, request atomic push (all refs update or none do)
Returns
SendPackResultSendPackResult
Raises
SendPackErrorif server rejects the pack data
GitProtocolErrorif atomic push is requested but server doesn't support it
dumb =

Undocumented

protocol_version =
def _discover_references(self, service: bytes, base_url: str, protocol_version: int | None = None, ref_prefix: Sequence[bytes] | None = None) -> tuple[dict[Ref, ObjectID | None], set[bytes], str, dict[Ref, Ref], dict[Ref, ObjectID]]:

Undocumented

def _get_url(self, path: str | bytes) -> str:

Undocumented

def _http_request(self, url: str, headers: dict[str, str] | None = None, data: bytes | Iterator[bytes] | None = None, raise_for_status: bool = True) -> tuple[HTTPResponse, Callable[[int], bytes]]:

Perform HTTP request.

Parameters
url:strRequest URL.
headers:dict[str, str] | NoneOptional custom headers to override defaults.
data:bytes | Iterator[bytes] | NoneRequest data.
raise_for_status:boolWhether to raise an exception for HTTP errors.
Returns
tuple[HTTPResponse, Callable[[int], bytes]]Tuple (response, read), where response is an urllib3 response object with additional content_type and redirect_location properties, and read is a consumable read method for the response data.
Raises
GitProtocolError
def _smart_request(self, service: str, url: str, data: bytes | Iterator[bytes]) -> tuple[HTTPResponse, Callable[[int], bytes]]:

Send a 'smart' HTTP request.

This is a simple wrapper around _http_request that sets a couple of extra headers.

_base_url =

Undocumented

_password =

Undocumented

_report_status_parser =
_url_with_auth: str | None =

Undocumented

_username =

Undocumented