Staging instance, all changes can be removed at any time

Skip to content

nar: Exclude only a single vcs type when computing hash

When computing the recursive nar hash of a directory fetched from a VCS like git or svn, only special directories related to the used VCS (.git or .svn) should be excluded. For instance when a directory was fetched from git, only .git folders should be excluded.

Before computing the nar hash in the fetch_data method, detect if fetched artifact is coming from a VCS (git, hg or svn) by checking the visit type of the loader and set vcs_type parameter of Nar constructor accordingly.

Related to swh-loader-git#4751.

It fixes nar hash computation for some git origins referenced by guix, for instance:

{
      "type": "git",
      "git_url": "https://github.com/s-andrews/FastQC",
      "integrity": "sha256-E6O3mLszo6KuM/nhRxeS0FaJgtbaI+o64v3OBWpuyQM=",
      "outputHashAlgo": "sha256",
      "outputHashMode": "recursive",
      "git_ref": "v0.11.9"
}
$ git clone https://github.com/s-andrews/FastQC
$ git checkout v0.11.9

Previously:

$ swh nar -x -H sha256 -f base64 FastQC/
6ZBuIfVO79U9iJGKEzoWQUuusk1dYmPb4MJo8yZI00s=

After:

$ swh nar -x -H sha256 -f base64 FastQC/
E6O3mLszo6KuM/nhRxeS0FaJgtbaI+o64v3OBWpuyQM=

Merge request reports

Loading