class RefsContainer:
Known subclasses: dulwich.refs.DictRefsContainer, dulwich.refs.DiskRefsContainer, dulwich.refs.NamespacedRefsContainer, dulwich.reftable.ReftableRefsContainer
Constructor: RefsContainer(logger)
A container for refs.
| Method | __contains__ |
Check if a reference exists. |
| Method | __delitem__ |
Remove a refname. |
| Method | __getitem__ |
Get the SHA1 for a reference name. |
| Method | __init__ |
Initialize RefsContainer with optional logger function. |
| Method | __iter__ |
Iterate over all reference keys. |
| Method | __setitem__ |
Set a reference name to point to the given SHA1. |
| Method | add |
Add a new reference only if it does not already exist. |
| Method | add |
Add the given refs as packed refs. |
| Method | allkeys |
All refs present in this container. |
| Method | as |
Return the contents of this container as a dictionary. |
| Method | follow |
Follow a reference name. |
| Method | get |
Get contents of the packed-refs file. |
| Method | get |
Return the cached peeled value of a ref, if available. |
| Method | get |
Get a dict with all symrefs in this container. |
| Method | import |
Import refs from another repository. |
| Method | keys |
Refs present in this container. |
| Method | pack |
Pack loose refs into packed-refs file. |
| Method | read |
Read a loose reference and return its contents. |
| Method | read |
Read a reference without following any references. |
| Method | remove |
Remove a refname only if it currently equals old_ref. |
| Method | set |
Set a refname to new_ref only if it currently equals old_ref. |
| Method | set |
Make a ref point at another ref. |
| Method | subkeys |
Refs present in this container under a base. |
| Method | _check |
Ensure a refname is valid and lives in refs or is HEAD. |
| Method | _log |
Undocumented |
| Instance Variable | _logger |
Undocumented |
Remove a refname.
This method does not follow symbolic references, even if applicable for the subclass.
- Note: This method unconditionally deletes the contents of a reference.
- To delete atomically only if the reference has not changed, use remove_if_equals().
| Parameters | |
name:Ref | The refname to delete. |
dulwich.reftable.ReftableRefsContainerGet the SHA1 for a reference name.
This method follows all symbolic references.
Callable[ [ bytes, bytes, bytes, (bytes | None), (int | None), (int | None), bytes], None] | None = None):
¶
dulwich.refs.DictRefsContainer, dulwich.refs.DiskRefsContainer, dulwich.refs.NamespacedRefsContainer, dulwich.reftable.ReftableRefsContainerInitialize RefsContainer with optional logger function.
Set a reference name to point to the given SHA1.
This method follows all symbolic references if applicable for the subclass.
- Note: This method unconditionally overwrites the contents of a
- reference. To update atomically only if the reference has not changed, use set_if_equals().
| Parameters | |
name:Ref | The refname to set. |
ref:ObjectID | The new sha the refname will refer to. |
Ref, ref: ObjectID, committer: bytes | None = None, timestamp: int | None = None, timezone: int | None = None, message: bytes | None = None) -> bool:
¶
dulwich.refs.DictRefsContainer, dulwich.refs.DiskRefsContainer, dulwich.refs.NamespacedRefsContainer, dulwich.reftable.ReftableRefsContainerAll refs present in this container.
dulwich.reftable.ReftableRefsContainerFollow a reference name.
- Returns: a tuple of (refnames, sha), wheres refnames are the names of
- references in the chain
dulwich.refs.DictRefsContainer, dulwich.refs.DiskRefsContainer, dulwich.refs.NamespacedRefsContainer, dulwich.reftable.ReftableRefsContainerGet contents of the packed-refs file.
Returns: Dictionary mapping ref names to SHA1s
- Note: Will return an empty dictionary when no packed-refs file is
- present.
dulwich.refs.DictRefsContainer, dulwich.refs.DiskRefsContainer, dulwich.refs.NamespacedRefsContainer, dulwich.reftable.ReftableRefsContainerReturn the cached peeled value of a ref, if available.
- Returns: The peeled value of the ref. If the ref is known not point to
- a tag, this will be the SHA the ref refers to. If the ref may point to a tag, but no cached information is available, None is returned.
| Parameters | |
name:Ref | Name of the ref to peel |
| Returns | |
ObjectID | None | Undocumented |
Ref, other: Mapping[ Ref, ObjectID | None], committer: bytes | None = None, timestamp: bytes | None = None, timezone: bytes | None = None, message: bytes | None = None, prune: bool = False):
¶
Import refs from another repository.
| Parameters | |
base:Ref | Base ref to import into (e.g., b'refs/remotes/origin') |
other:Mapping[ | Dictionary of refs to import |
committer:bytes | None | Optional committer for reflog |
timestamp:bytes | None | Optional timestamp for reflog |
timezone:bytes | None | Optional timezone for reflog |
message:bytes | None | Optional message for reflog |
prune:bool | If True, remove refs not in other |
Pack loose refs into packed-refs file.
| Parameters | |
all:bool | If True, pack all refs. If False, only pack tags. |
Ref, old_ref: ObjectID | None, committer: bytes | None = None, timestamp: int | None = None, timezone: int | None = None, message: bytes | None = None) -> bool:
¶
dulwich.refs.DictRefsContainer, dulwich.refs.DiskRefsContainer, dulwich.refs.NamespacedRefsContainer, dulwich.reftable.ReftableRefsContainerRemove a refname only if it currently equals old_ref.
This method does not follow symbolic references, even if applicable for the subclass. It can be used to perform an atomic compare-and-delete operation.
Returns: True if the delete was successful, False otherwise.
| Parameters | |
name:Ref | The refname to delete. |
oldObjectID | None | The old sha the refname must refer to, or None to delete unconditionally. |
committer:bytes | None | Optional committer name/email |
timestamp:int | None | Optional timestamp |
timezone:int | None | Optional timezone |
message:bytes | None | Message for reflog |
| Returns | |
bool | Undocumented |
Ref, old_ref: ObjectID | None, new_ref: ObjectID, committer: bytes | None = None, timestamp: int | None = None, timezone: int | None = None, message: bytes | None = None) -> bool:
¶
dulwich.refs.DictRefsContainer, dulwich.refs.DiskRefsContainer, dulwich.refs.NamespacedRefsContainer, dulwich.reftable.ReftableRefsContainerSet a refname to new_ref only if it currently equals old_ref.
This method follows all symbolic references if applicable for the subclass, and can be used to perform an atomic compare-and-swap operation.
Returns: True if the set was successful, False otherwise.
| Parameters | |
name:Ref | The refname to set. |
oldObjectID | None | The old sha the refname must refer to, or None to set unconditionally. |
newObjectID | The new sha the refname will refer to. |
committer:bytes | None | Optional committer name/email |
timestamp:int | None | Optional timestamp |
timezone:int | None | Optional timezone |
message:bytes | None | Message for reflog |
| Returns | |
bool | Undocumented |
Ref, other: Ref, committer: bytes | None = None, timestamp: int | None = None, timezone: int | None = None, message: bytes | None = None):
¶
Ensure a refname is valid and lives in refs or is HEAD.
HEAD is not a valid refname according to git-check-ref-format, but this class needs to be able to touch HEAD. Also, check_ref_format expects refnames without the leading 'refs/', but this class requires that so it cannot touch anything outside the refs dir (or HEAD).
| Parameters | |
name:Ref | The name of the reference. |
| Raises | |
KeyError | if a refname is not HEAD or is otherwise not valid. |