datalad_next.iter_collections.gittree

Report on the content of a Git tree-ish

The main functionality is provided by the iter_gittree() function.

class datalad_next.iter_collections.gittree.GitTreeItem(name: str, gitsha: str | None = None, gittype: GitTreeItemType | None = None)[source]

Bases: PathBasedItem

PathBasedItem with a relative path as a name (in POSIX conventions)

gitsha: str | None = None
gittype: GitTreeItemType | None = None
name: str
property path: PurePosixPath

Returns the item name as a PurePosixPath instance

class datalad_next.iter_collections.gittree.GitTreeItemType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Enumeration of item types of Git trees

directory = 'directory'
executablefile = 'executablefile'
file = 'file'
submodule = 'submodule'
datalad_next.iter_collections.gittree.iter_gittree(path: Path, treeish: str, *, recursive: str = 'repository') Generator[GitTreeItem, None, None][source]

Uses git ls-tree to report on a tree in a Git repository

Parameters:
  • path (Path) -- Path of a directory in a Git repository to report on. This directory need not be the root directory of the repository, but must be part of the repository. If the directory is not the root directory of a non-bare repository, the iterator is constrained to items underneath that directory.

  • recursive ({'repository', 'no'}, optional) -- Behavior for recursion into subtrees. By default (repository), all tree within the repository underneath path) are reported, but not tree within submodules. If no, only direct children are reported on.

Yields:

GitTreeItem -- The name attribute of an item is a str with the corresponding (relative) path, as reported by Git (in POSIX conventions).