Repository¶
didactic.api.Repository ¶
Filesystem-backed panproto repository.
Wraps a panproto.Repository. Construction is
via the Repository.init and
Repository.open class methods rather
than the bare constructor; the constructor accepts an already-open
handle and is mostly for internal use.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inner
|
Repository
|
required |
Notes
The wrapper delegates almost every operation to the inner panproto handle. The reason it exists, rather than re-exporting panproto's type, is to keep didactic's public API independent of panproto's Python binding details (attribute names, argument keywords, etc.) as panproto evolves.
Examples:
>>> import didactic.api as dx
>>> repo = dx.Repository.init("/tmp/my-repo")
>>> repo.head() is None
True
init
classmethod
¶
init(path: str | PathLike[str]) -> Repository
Initialise a new repository at path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
Directory in which to create the |
required |
Returns:
| Type | Description |
|---|---|
Repository
|
A handle to the newly initialised repository. |
Raises:
| Type | Description |
|---|---|
VcsError
|
If a repository already exists at |
open
classmethod
¶
open(path: str | PathLike[str]) -> Repository
Open an existing repository at path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | PathLike[str]
|
Directory containing a |
required |
Returns:
| Type | Description |
|---|---|
Repository
|
A handle to the existing repository. |
Raises:
| Type | Description |
|---|---|
VcsError
|
If no repository exists at |
head ¶
Resolve HEAD to a commit object id.
Returns:
| Type | Description |
|---|---|
str or None
|
The commit id, or |
head_state ¶
Describe the current HEAD state.
Returns:
| Type | Description |
|---|---|
str
|
A descriptor string from panproto. For a freshly
initialised repository this is typically
|
list_branches ¶
Return the list of branches.
Returns:
| Type | Description |
|---|---|
list of (str, str)
|
One |
list_tags ¶
Return the list of tags.
Returns:
| Type | Description |
|---|---|
list of (str, str)
|
One |
log ¶
List commits reachable from HEAD, newest first.
Returns:
| Type | Description |
|---|---|
list of dict
|
One commit-record dict per commit, in newest-first order. The exact shape is panproto-defined; callers that depend on specific keys should consult panproto's documentation. |
resolve_ref ¶
Resolve a ref expression to a commit id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ref
|
str
|
A branch name, tag name, or commit-id prefix. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The full commit id. |
Raises:
| Type | Description |
|---|---|
VcsError
|
If |
add ¶
Stage target for the next commit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Schema | type
|
Either a |
required |
Notes
Staging is additive: subsequent calls accumulate in the index until a commit flushes it.
commit ¶
Create a commit with message and author.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The commit message. |
required |
author
|
str
|
The commit author. Free-form string; the conventional
shape is |
required |
skip_verify
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The new commit's object id. |
Raises:
| Type | Description |
|---|---|
VcsError
|
If nothing is staged or panproto rejects the commit. |
create_branch ¶
Create a new branch name pointing at commit_id.