class Repo(BaseRepo):
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__ |
Undocumented |
Method | __exit__ |
Undocumented |
Method | __init__ |
Open a repository. |
Method | __repr__ |
Undocumented |
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 |
Get a file from the control dir with a specific name. |
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 | reset |
Reset the index back to a specific tree. |
Method | set |
Set the description for this repository. |
Method | stage |
Stage a set of paths. |
Method | unstage |
unstage specific file in the index |
Instance Variable | bare |
Whether this is a bare repository |
Instance Variable | path |
Path to the working copy (if it exists) or repository control directory (if the repository is bare) |
Instance Variable | symlink |
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 | _put |
Write a file to the control dir with the given name and contents. |
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 | do |
Create a new commit. |
Method | fetch |
Fetch objects into another repository. |
Method | fetch |
Fetch the missing objects required for a set of revisions. |
Method | fetch |
Fetch the pack data 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 |
Undocumented |
Method | update |
Update the list of shallow objects. |
Instance Variable | hooks |
Undocumented |
Instance Variable | object |
Dictionary-like object for accessing the objects |
Instance Variable | refs |
Dictionary-like object with the refs in this repository |
Method | _add |
Add or modify graftpoints |
Method | _get |
Undocumented |
Method | _get |
Determine the identity to use for new commits. |
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 | The directory to start discovery from (defaults to '.') |
Create a new bare repository.
path should already exist and be an empty directory.
Returns: a Repo
instance
Parameters | |
path | Path to create bare repository in |
mkdir | Undocumented |
object | Undocumented |
dulwich.repo.BaseRepo.__init__
Open a repository.
This shouldn't be called directly, but rather through one of the base classes, such as MemoryRepo or Repo.
Parameters | |
root:str | Undocumented |
objectOptional[ | Object store to use |
bare:Optional[ | Undocumented |
refs | Refs container to use |
Clone this repository.
Returns: Created repository as Repo
Parameters | |
target | Target path |
mkdir | Create the target directory |
bare | Whether to create a bare repository |
origin | Base name for refs in target repository cloned from this repository |
checkout | Whether or not to check-out HEAD after cloning |
branch | Optional branch or tag to be used as HEAD in the new repository instead of this repository's HEAD. |
progress | Optional progress function |
depth | Depth at which to fetch |
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_config
Retrieve the config object.
Returns: ConfigFile
object for the .git/config file.
Returns | |
ConfigFile | Undocumented |
dulwich.repo.BaseRepo.get_description
Retrieve the description of this repository.
Returns: A string describing the repository or None.
dulwich.repo.BaseRepo.get_named_file
Get 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 | The path to the file, relative to the control dir. |
basedir | Optional argument that specifies an alternative to the control dir. |
dulwich.repo.BaseRepo.open_index
Open the index for this repository.
Returns: The matching Index
Returns | |
Index | Undocumented |
Raises | |
NoIndexPresent | If no index is present |
dulwich.repo.BaseRepo.set_description
Set the description for this repository.
Parameters | |
description | Text to set as description for this repository. |
Stage a set of paths.
Parameters | |
fsUnion[ | List of paths, relative to the repository path |
Path to the working copy (if it exists) or repository control directory (if the repository is bare)
Create a new working directory linked to a repository.
Returns: Repo
instance
Parameters | |
path | Path in which to create the working tree. |
main | Main repository to reference |
identifier | Worktree identifier |
mkdir | Whether to create the directory |
dulwich.repo.BaseRepo._del_named_file
Delete 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.
dulwich.repo.BaseRepo._put_named_file
Write a file to the control dir with the given name and contents.
Parameters | |
path | The path to the file, relative to the control dir. |
contents | A string to write to the file. |