swh.loader.git.directory module#

swh.loader.git.directory.git() str[source]#

Get the path to the git executable.


EnvironmentError if no opam executable is found

swh.loader.git.directory.clone_repository(git_url: str, git_ref: str, target: Path) Path[source]#

Clone git_url repository at git_ref commit, tag or branch.

This function can raise for various reasons. This is expected to be caught by the main loop in the loader.

swh.loader.git.directory.list_git_tree(dirpath: str, dirname: str, entries: Iterable[Any]) bool[source]#

List a git tree. This ignores any repo_path/.git/* and empty folders. This is a filter for directory_to_objects() to ignore specific directories.

class swh.loader.git.directory.GitCheckoutLoader(*args, **kwargs)[source]#

Bases: BaseDirectoryLoader

Git directory loader in charge of ingesting a git tree at a specific commit, tag or branch into the swh archive.

As per the standard git hash computations, this ignores the .git and the empty directories.

The output snapshot is of the form:

id: <bytes>
    target_type: alias
    target: <git-ref>
    target_type: directory
    target: <directory-id>
visit_type: str = 'git-checkout'#
fetch_artifact() Iterator[Path][source]#

This fetches an artifact representation and yields its associated local representation (as Path). Depending on the implementation, this may yield contents coming from a remote location, or directories coming from tarball, svn tree, git tree, hg tree, …


NotFound if nothing is found; ValueError in case of mismatched checksums

build_snapshot() Snapshot[source]#

Build snapshot without losing the git reference context.

origin: Origin#
loaded_snapshot_id: Optional[bytes]#
parent_origins: Optional[List[Origin]]#

If the given origin is a “forge fork” (ie. created with the “Fork” button of GitHub-like forges), build_extrinsic_origin_metadata() sets this to a list of origins it was forked from; closest parent first.

snapshot: Optional[model.Snapshot]#
artifact_path: Optional[Path]#
mirror_urls: List[str]#
directory: Optional[from_disk.Directory]#
cnts: List[model.Content]#
skipped_cnts: List[model.SkippedContent]#
dirs: List[model.Directory]#