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.
- Parameters:
- Returns
A tuple: - temporary folder: containing the mounted repository - repo_path, path to the mounted repository inside the temporary folder
- Raises
ValueError in case of failure to run the command to uncompress
- swh.loader.git.utils.check_date_time(timestamp)[source]#
Check date time for overflow errors.
- Parameters:
timestamp (timestamp) – Timestamp in seconds
- Raises:
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, 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, SnapshotBranch | None], dangling_branches: Dict[HexBytes, bytes], logger: Logger, origin_url: str) None [source]#
- swh.loader.git.utils.raise_not_found_repository()[source]#
Catches all kinds of exceptions which translate to an inexistent repository and reraise as a NotFound exception. Any other exceptions are propagated to the caller.
- Raises:
NotFound – instead of HTTPUnauthorized, NotGitRepository and any GitProtocol with specific error message relative to an inexistent repository.
* – Any other exceptions raised within the try block