swh.loader.git.from_disk module#

class swh.loader.git.from_disk.GitLoaderFromArchive(*args, archive_path: str, **kwargs)[source]#

Bases: GitLoader

Load a git repository from an archive.

This loader ingests a git repository compressed into an archive. The supported archive formats are .zip and .tar.gz.

It notably supports the loading of a repository with missing objects that can be obtained by using the filter option from the git clone command (requires git server to have such feature implemented), for instance:

# clone a repository without fetching blobs not reachable from HEAD
$ git clone <repo_url> --filter=blob:none

# clone a repository without fetching trees and blobs not reachable from HEAD
$ git clone <repo_url> --filter=tree:0

It can be useful to load such repositories when writing tests that do not need to process blob and tree objects so we can produce an archive of smaller size.

From an input tarball named my-git-repo.zip, the following layout is expected in it:

my-git-repo/
├── .git
│   ├── branches
│   ├── COMMIT_EDITMSG
│   ├── config
│   ├── description
│   ├── HEAD
...

Nevertheless, the loader is able to ingest tarballs with the following layouts too:

.
├── .git
│   ├── branches
│   ├── COMMIT_EDITMSG
│   ├── config
│   ├── description
│   ├── HEAD
...

or:

other-repo-name/
├── .git
│   ├── branches
│   ├── COMMIT_EDITMSG
│   ├── config
│   ├── description
│   ├── HEAD
...

Initialize the bulk updater.

Parameters:
  • repo_representation – swh’s repository representation

  • remote (which is in charge of filtering between known and)

  • data.

  • ...

  • incremental – If True, the default, this starts from the last known snapshot (if any) references. Otherwise, this loads the full repository.

project_name_from_archive(archive_path)[source]#

Compute the project name from the archive’s path.

fetch_pack_from_origin(origin_url: str, base_repo: RepoRepresentation, do_activity: Callable[[bytes], None])[source]#

Fetch a pack from the origin