Remotes¶
- Repository.remotes¶
Returns all configured remotes
- Repository.create_remote(name, url) → Remote¶
Creates a new remote.
The Remote type¶
- class pygit2.Remote(repo, ptr)¶
- add_fetch(refspec)¶
Add a fetch refspec to the remote
- add_push(refspec)¶
Add a push refspec to the remote
- credentials(url, username_from_url, allowed_types)¶
Credentials callback
If the remote server requires authentication, this function will be called and its return value used for authentication. Override it if you want to be able to perform authentication.
Parameters:
- url (str) – The url of the remote.
- username_from_url (str or None) – Username extracted from the url, if any.
- allowed_types (int) – Credential types supported by the remote.
Return value: credential
- delete()¶
Remove this remote
All remote-tracking branches and configuration settings for the remote will be removed.
- fetch(signature, message) → TransferProgress¶
Perform a fetch against this remote.
- fetch_refspecs¶
Refspecs that will be used for fetching
- get_refspec(n) → Refspec¶
Return the refspec at the given position
- name¶
Name of the remote
- push(refspec, signature, message)¶
Push the given refspec to the remote. Raises GitError on error.
Parameters: - spec (str) – push refspec to use
- signature (Signature) – signature to use when updating the tips
- message (str) – message to use when updating the tips
- push_refspecs¶
Refspecs that will be used for pushing
- push_url¶
Push url of the remote
- refspec_count¶
Total number of refspecs in this remote
- rename(new_name)¶
Rename this remote
Returns a list of fetch refspecs which were not in the standard format and thus could not be remapped
- save()¶
Save a remote to its repository’s configuration
- sideband_progress(string)¶
Progress output callback
Override this function with your own progress reporting function
Parameters: string (str) – Progress otuput from the remote
- transfer_progress(stats)¶
Transfer progress callback
Override with your own function to report transfer progress.
Parameters: stats (TransferProgress) – The progress up to now
- update_tips(refname, old, new)¶
Update tips callabck
Override with your own function to report reference updates
Parameters: - refname (str) – the name of the reference that’s being updated
- old (Oid) – the reference’s old value
- new (Oid) – the reference’s new value
- url¶
Url of the remote
The TransferProgress type¶
This class contains the data which is available to us during a fetch.
- class pygit2.remote.TransferProgress(tp)¶
Progress downloading and indexing data during a fetch
- indexed_deltas = None¶
Deltas which have been indexed
- indexed_objects = None¶
Objects which have been indexed
- local_objects = None¶
Local objects which were used to fix the thin pack
- received_bytes = None¶
“Number of bytes received up to now
- received_objects = None¶
Objects which have been received up to now
- total_deltas = None¶
Total number of deltas in the pack
- total_objects = None¶
Total number of objects to download
The Refspec type¶
- class pygit2.refspec.Refspec(owner, ptr)¶
- direction¶
Direction of this refspec (fetch or push)
- dst¶
Destinaton or rhs of the refspec
- dst_matches(str) → Bool¶
Returns whether the given string matches the destination of this refspec
- force¶
Whether this refspeca llows non-fast-forward updates
- rtransform(ref)¶
transform(str) -> str
Transform a reference name according to this refspec from the lhs to the rhs
- src¶
Source or lhs of the refspec
- src_matches(str) → Bool¶
Returns whether the given string matches the source of this refspec
- string¶
String which was used to create this refspec
- transform(str) → str¶
Transform a reference name according to this refspec from the lhs to the rhs.
Credentials¶
- Remote.credentials(url, username_from_url, allowed_types)
Credentials callback
If the remote server requires authentication, this function will be called and its return value used for authentication. Override it if you want to be able to perform authentication.
Parameters:
- url (str) – The url of the remote.
- username_from_url (str or None) – Username extracted from the url, if any.
- allowed_types (int) – Credential types supported by the remote.
Return value: credential
There are two types of credentials: username/password and SSH key pairs. Both pygit2.UserPass and pygit2.Keypair are callable objects, with the appropriate signature for the credentials callback. They will ignore all the arguments and return themselves. This is useful for scripts where the credentials are known ahead of time. More complete interfaces would want to look up in their keychain or ask the user for the data to use in the credentials.
- class pygit2.UserPass(username, password)¶
Username/Password credentials
This is an object suitable for passing to a remote’s credentials callback and for returning from said callback.
- class pygit2.Keypair(username, pubkey, privkey, passphrase)¶
SSH key pair credentials
This is an object suitable for passing to a remote’s credentials callback and for returning from said callback.
Parameters: - username (str) – the username being used to authenticate with the remote server
- pubkey (str) – the path to the user’s public key file
- privkey (str) – the path to the user’s private key file
- passphrase (str) – the password used to decrypt the private key file