southwark.repo
¶
Modified Dulwich repository object.
New in version 0.3.0.
Classes:
|
Modified Dulwich repository object. |
Data:
Invariant |
Functions:
|
Determine the identity to use for new commits. |
-
class
Repo
(root, object_store=None, bare=None)[source]¶ Bases:
Repo
Modified Dulwich repository object.
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.
- Parameters:
root (
str
)
Methods:
do_commit
([message, committer, author, ...])Create a new commit.
init
(path[, mkdir])Create a new repository.
init_bare
(path[, mkdir])Create a new bare repository.
Returns a mapping of remote names to remote URLs, for the repo's current remotes.
reset_to
(sha)Reset the state of the repository to the given commit sha.
-
do_commit
(message=None, committer=None, author=None, commit_timestamp=None, commit_timezone=None, author_timestamp=None, author_timezone=None, tree=None, encoding=None, ref=b'HEAD', merge_heads=None)[source]¶ Create a new commit.
If not specified, committer and author default to
get_user_identity(..., 'COMMITTER')
andget_user_identity(..., 'AUTHOR')
respectively.- Parameters:
message (
Union
[str
,bytes
,None
]) – Commit message. DefaultNone
.committer (
Union
[str
,bytes
,None
]) – Committer fullname. DefaultNone
.author (
Union
[str
,bytes
,None
]) – Author fullname. DefaultNone
.commit_timestamp (
Optional
[float
]) – Commit timestamp (defaults to now). DefaultNone
.commit_timezone (
Optional
[float
]) – Commit timestamp timezone (defaults to GMT). DefaultNone
.author_timestamp (
Optional
[float
]) – Author timestamp (defaults to commit timestamp). DefaultNone
.author_timezone (
Optional
[float
]) – Author timestamp timezone (defaults to commit timestamp timezone). DefaultNone
.tree (
Optional
[Any
]) – SHA1 of the tree root to use (if not specified the current index will be committed). DefaultNone
.encoding (
Union
[str
,bytes
,None
]) – Encoding. DefaultNone
.ref (
bytes
) – Optional ref to commit to (defaults to current branch). Defaultb'HEAD'
.merge_heads (
Optional
[Any
]) – Merge heads (defaults to .git/MERGE_HEADS). DefaultNone
.
- Return type:
- Returns:
New commit SHA1
-
_R
= TypeVar(_R, bound=Repo)¶ Type:
TypeVar
Invariant
TypeVar
bound tosouthwark.repo.Repo
.
-
get_user_identity
(config, kind=None)[source]¶ Determine the identity to use for new commits.
If kind is set, this first checks
GIT_${KIND}_NAME
andGIT_${KIND}_EMAIL
.If those variables are not set, then it will fall back to reading the
user.name
anduser.email
settings from the specified configuration.If that also fails, then it will fall back to using the current users’ identity as obtained from the host system (e.g. the gecos field,
$EMAIL
,$USER@$(hostname -f)
.