Git#
Define and manage NWB namespaces in external repositories
- pydantic model NamespaceRepo#
Definition of one NWB namespaces file to import from a git repository
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
__init__ uses __pydantic_self__ instead of the more common self for the first arg to allow self as a field name.
- Fields:
- field name: str [Required]#
Short name used to refer to this namespace (usually equivalent to the name field within a namespaces NWB list)
- exception GitError#
- class GitRepo(namespace: NamespaceRepo, commit: str | None = None, path: Path | None = None)#
Manage a temporary git repository that provides the NWB yaml files
- Parameters:
namespace (
NamespaceRepo
) – The namespace repository to clone!commit (str) – A specific commit or tag to check out
path (
pathlib.Path
) – A directory to clone to - ifNone
, usegit_dir
/NamespaceRepo.name
- property commit: str | None#
The intended commit to check out.
If
None
: ifNamespaceRepo.versions
, use the last version. Otherwise useHEAD
Should match
active_commit
, differs semantically in that it is used to set the active_commit, whileactive_commit
reads what commit is actually checked out
- property tag: str#
Get/set the currently checked out repo tag.
- Returns:
the result of
git describe --tags
, which is equal to the tag if it is checked out, otherwise it is the tag plus some number of revisions and the short hash.- Return type:
Examples
>>> repo = GitRepo(NWB_CORE_REPO) >>> repo.clone() >>> # Check out a tag specifically >>> repo.tag = "2.6.0" >>> repo.tag "2.6.0" >>> # Now check out a commit some number after the tag. >>> repo.commit = "gec0a879" >>> repo.tag "2.6.0-5-gec0a879"
- property default_branch: str#
Default branch as configured for this repository
Gotten from
git symbolic-ref
- property detached_head: bool#
Detect if repo is in detached HEAD state that might need to be undone before checking out eg. a HEAD commit.
- Returns:
True
if in detached head mode,False
otherwise- Return type:
- check() bool #
Check if the repository is already cloned and checked out
- Returns:
(bool) True if present, False if not