swh.loader.git.utils module#

Utilities helper functions

swh.loader.git.utils.init_git_repo_from_archive(project_name, archive_path, root_temp_dir='/tmp')[source]#

Given a path to an archive containing a git repository.

Uncompress that archive to a temporary location and returns the path.

If any problem whatsoever is raised, clean up the temporary location.

  • project_name (str) – Project’s name

  • archive_path (str) – Full path to the archive

  • root_temp_dir (str) – Optional temporary directory mount point (default to /tmp)


A tuple: - temporary folder: containing the mounted repository - repo_path, path to the mounted repository inside the temporary folder


ValueError in case of failure to run the command to uncompress


Check date time for overflow errors.


timestamp (timestamp) – Timestamp in seconds


Any error raised by datetime fromtimestamp conversion error.

swh.loader.git.utils.ignore_branch_name(branch_name: bytes) bool[source]#

Should the git loader ignore the branch named branch_name?

swh.loader.git.utils.filter_refs(refs: Mapping[bytes, Union[bytes, HexBytes]]) Dict[bytes, HexBytes][source]#

Filter the refs dictionary using the policy set in ignore_branch_name

swh.loader.git.utils.warn_dangling_branches(branches: Dict[bytes, Optional[SnapshotBranch]], dangling_branches: Dict[HexBytes, bytes], logger: Logger, origin_url: str) None[source]#