class Repo(BaseRepo):
Constructors: Repo.discover(start), Repo.init(path, mkdir, config, default_branch, ...), Repo.init_bare(path, mkdir, object_store, config, ...), Repo(root, object_store, bare), Repo._init_maybe_bare(path, controldir, bare, object_store, ...), Repo._init_new_working_directory(path, main_repo, identifier, mkdir, ...)
A git repository backed by local disk.
To open an existing repository, call the constructor with the path of the repository.
To create a new repository, use the Repo.init class method.
Note that a repository object may hold on to resources such as file handles for performance reasons; call .close() to free up those resources.
| Class Method | discover |
Iterate parent directories to discover a repository. |
| Class Method | init |
Create a new repository. |
| Class Method | init |
Create a new bare repository. |
| Method | __enter__ |
Enter context manager. |
| Method | __exit__ |
Exit context manager and close repository. |
| Method | __init__ |
Open a repository on disk. |
| Method | __repr__ |
Return string representation of this repository. |
| Method | clone |
Clone this repository. |
| Method | close |
Close any files opened by this repository. |
| Method | commondir |
Return the path of the common directory. |
| Method | controldir |
Return the path of the control directory. |
| Method | get |
Return a BlobNormalizer object. |
| Method | get |
Retrieve the config object. |
| Method | get |
Retrieve the description of this repository. |
| Method | get |
Read gitattributes for the repository. |
| Method | get |
Get a file from the control dir with a specific name. |
| Method | get |
Get the appropriate rebase state manager for this repository. |
| Method | get |
Get the working tree for this repository. |
| Method | get |
Get the worktree-specific config. |
| Method | has |
Check if an index is present. |
| Method | index |
Return path to the index file. |
| Method | open |
Open the index for this repository. |
| Method | read |
Read reflog entries for a reference. |
| Method | set |
Set the description for this repository. |
| Instance Variable | bare |
Whether this is a bare repository |
| Instance Variable | filter |
Undocumented |
| Instance Variable | object |
Undocumented |
| Instance Variable | object |
Undocumented |
| Instance Variable | path |
Path to the working copy (if it exists) or repository control directory (if the repository is bare) |
| Instance Variable | refs |
Undocumented |
| Instance Variable | worktrees |
Undocumented |
| Class Method | _init |
Undocumented |
| Class Method | _init |
Create a new working directory linked to a repository. |
| Method | _del |
Delete a file in the control directory with the given name. |
| Method | _determine |
Probe the file-system to determine whether permissions can be trusted. |
| Method | _determine |
Probe the filesystem to determine whether symlinks can be created. |
| Method | _get |
Get condition matchers for includeIf conditions. |
| Method | _get |
Get shared repository file and directory permissions from config. |
| Method | _put |
Write a file to the control dir with the given name and contents. |
| Method | _read |
Read .gitattributes file from working tree. |
| Method | _reflog |
Undocumented |
| Method | _write |
Undocumented |
| Instance Variable | _commondir |
Undocumented |
| Instance Variable | _controldir |
Undocumented |
| Instance Variable | _graftpoints |
Undocumented |
Inherited from BaseRepo:
| Method | __contains__ |
Check if a specific Git object or ref is present. |
| Method | __delitem__ |
Remove a ref. |
| Method | __getitem__ |
Retrieve a Git object by SHA1 or ref. |
| Method | __setitem__ |
Set a ref. |
| Method | fetch |
Fetch objects into another repository. |
| Method | fetch |
Fetch the pack data required for a set of revisions. |
| Method | find |
Fetch the missing objects required for a set of revisions. |
| Method | generate |
Generate pack data objects for a set of wants/haves. |
| Method | get |
Return a config stack for this repository. |
| Method | get |
Retrieve a graph walker. |
| Method | get |
Retrieve the object with the specified SHA. |
| Method | get |
Retrieve the parents of a specific commit. |
| Method | get |
Get the peeled value of a ref. |
| Method | get |
Get dictionary with all refs. |
| Method | get |
Get the set of shallow commits. |
| Method | get |
Obtain a walker for this repository. |
| Method | head |
Return the SHA1 pointed at by HEAD. |
| Method | parents |
Get a parents provider for this repository. |
| Method | update |
Update the list of shallow objects. |
| Instance Variable | hooks |
Undocumented |
| Property | notes |
Access notes functionality for this repository. |
| Method | _add |
Add or modify graftpoints. |
| Method | _change |
Change the object format of this repository. |
| Method | _get |
Undocumented |
| Method | _get |
Determine the identity to use for new commits. |
| Method | _init |
Initialize repository configuration. |
| Method | _init |
Initialize a default set of named files. |
| Method | _read |
Undocumented |
| Method | _remove |
Remove graftpoints. |
Iterate parent directories to discover a repository.
Return a Repo object for the first parent directory that looks like a Git repository.
| Parameters | |
start:str | bytes | os.PathLike[ | The directory to start discovery from (defaults to '.') |
| Returns | |
Repo | Undocumented |
str | bytes | os.PathLike[ str], *, mkdir: bool = False, config: StackedConfig | None = None, default_branch: bytes | None = None, symlinks: bool | None = None, format: int | None = None, shared_repository: str | bool | None = None, object_format: str | None = None) -> Repo:
¶
Create a new repository.
Returns: Repo instance
| Parameters | |
path:str | bytes | os.PathLike[ | Path in which to create the repository |
mkdir:bool | Whether to create the directory |
config:StackedConfig | None | Configuration object |
defaultbytes | None | Default branch name |
symlinks:bool | None | Whether to support symlinks |
format:int | None | Repository format version (defaults to 0) |
sharedstr | bool | None | Shared repository setting (group, all, umask, or octal) |
objectstr | None | Object format to use ("sha1" or "sha256", defaults to "sha1") |
| Returns | |
Repo | Undocumented |
str | bytes | os.PathLike[ str], *, mkdir: bool = False, object_store: PackBasedObjectStore | None = None, config: StackedConfig | None = None, default_branch: bytes | None = None, format: int | None = None, shared_repository: str | bool | None = None, object_format: str | None = None) -> Repo:
¶
Create a new bare repository.
path should already exist and be an empty directory.
Returns: a Repo instance
| Parameters | |
path:str | bytes | os.PathLike[ | Path to create bare repository in |
mkdir:bool | Whether to create the directory |
objectPackBasedObjectStore | None | Object store to use |
config:StackedConfig | None | Configuration object |
defaultbytes | None | Default branch name |
format:int | None | Repository format version (defaults to 0) |
sharedstr | bool | None | Shared repository setting (group, all, umask, or octal) |
objectstr | None | Object format to use ("sha1" or "sha256", defaults to "sha1") |
| Returns | |
Repo | Undocumented |
type[ BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None):
¶
Exit context manager and close repository.
str | bytes | os.PathLike[ str], object_store: PackBasedObjectStore | None = None, bare: bool | None = None):
¶
dulwich.repo.BaseRepo.__init__Open a repository on disk.
| Parameters | |
root:str | bytes | os.PathLike[ | Path to the repository's root. |
objectPackBasedObjectStore | None | ObjectStore to use; if omitted, we use the repository's default object store |
bare:bool | None | True if this is a bare repository. |
str | bytes | os.PathLike[ str], *, mkdir: bool = True, bare: bool = False, origin: bytes = b'origin', checkout: bool | None = None, branch: bytes | None = None, progress: Callable[ [ str], None] | None = None, depth: int | None = None, symlinks: bool | None = None) -> Repo:
¶
Clone this repository.
Returns: Created repository as Repo
| Parameters | |
targetstr | bytes | os.PathLike[ | Target path |
mkdir:bool | Create the target directory |
bare:bool | Whether to create a bare repository |
origin:bytes | Base name for refs in target repository cloned from this repository |
checkout:bool | None | Whether or not to check-out HEAD after cloning |
branch:bytes | None | Optional branch or tag to be used as HEAD in the new repository instead of this repository's HEAD. |
progress:Callable[ | Optional progress function |
depth:int | None | Depth at which to fetch |
symlinks:bool | None | Symlinks setting (default to autodetect) |
| Returns | |
Repo | Undocumented |
Return the path of the common directory.
For a main working tree, it is identical to controldir().
For a linked working tree, it is the control directory of the main working tree.
dulwich.repo.BaseRepo.get_configRetrieve the config object.
Returns: ConfigFile object for the .git/config file.
dulwich.repo.BaseRepo.get_descriptionRetrieve the description of this repository.
Returns: Description as bytes or None.
dulwich.repo.BaseRepo.get_gitattributesRead gitattributes for the repository.
| Parameters | |
tree:bytes | None | Tree SHA to read .gitattributes from (defaults to HEAD) |
| Returns | |
GitAttributes | GitAttributes object that can be used to match paths |
dulwich.repo.BaseRepo.get_named_fileGet a file from the control dir with a specific name.
Although the filename should be interpreted as a filename relative to the control dir in a disk-based Repo, the object returned need not be pointing to a file in that location.
Returns: An open file object, or None if the file does not exist.
| Parameters | |
path:str | bytes | The path to the file, relative to the control dir. |
basedir:str | None | Optional argument that specifies an alternative to the control dir. |
| Returns | |
BinaryIO | None | Undocumented |
Get the appropriate rebase state manager for this repository.
Returns: DiskRebaseStateManager instance
dulwich.repo.BaseRepo.get_worktreeGet the working tree for this repository.
| Returns | |
WorkTree | WorkTree instance for performing working tree operations |
dulwich.repo.BaseRepo.open_indexOpen the index for this repository.
Returns: The matching Index
| Raises | |
NoIndexPresent | If no index is present |
Read reflog entries for a reference.
| Parameters | |
ref:bytes | Reference name (e.g. b'HEAD', b'refs/heads/master') |
| Returns | |
Generator[ | Undocumented |
| Yields | |
| reflog.Entry objects in chronological order (oldest first) |
dulwich.repo.BaseRepo.set_descriptionSet the description for this repository.
| Parameters | |
description:bytes | Text to set as description for this repository. |
str | bytes | os.PathLike[ str], controldir: str | bytes | os.PathLike[ str], bare: bool, object_store: PackBasedObjectStore | None = None, config: StackedConfig | None = None, default_branch: bytes | None = None, symlinks: bool | None = None, format: int | None = None, shared_repository: str | bool | None = None, object_format: str | None = None) -> Repo:
¶
Undocumented
str | bytes | os.PathLike[ str], main_repo: Repo, identifier: str | None = None, mkdir: bool = False, relative_paths: bool = False) -> Repo:
¶
Create a new working directory linked to a repository.
Returns: Repo instance
| Parameters | |
path:str | bytes | os.PathLike[ | Path in which to create the working tree. |
mainRepo | Main repository to reference |
identifier:str | None | Worktree identifier |
mkdir:bool | Whether to create the directory |
relativebool | Whether to use relative paths for gitdir references |
| Returns | |
Repo | Undocumented |
dulwich.repo.BaseRepo._del_named_fileDelete a file in the control directory with the given name.
Probe the file-system to determine whether permissions can be trusted.
Returns: True if permissions can be trusted, False otherwise.
Probe the filesystem to determine whether symlinks can be created.
Returns: True if symlinks can be created, False otherwise.
Get condition matchers for includeIf conditions.
Returns a dict of condition prefix to matcher function.