Page MenuHomeSoftware Heritage

snapshot: add support for 'alias' target type
ClosedPublic

Authored by haltode on Dec 4 2020, 12:29 PM.

Diff Detail

Repository
rDFUSE FUSE virtual file system
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D4665 (id=16553)

Rebasing onto f3363d909f...

Current branch diff-target is up to date.
Changes applied before test
commit 1357dce791027fc9d8fefc1feae624a731702ff3
Author: Thibault Allançon <haltode@gmail.com>
Date:   Fri Dec 4 11:56:17 2020 +0100

    snapshot: add support for 'alias' target type
    
    Fix T2840.

See https://jenkins.softwareheritage.org/job/DFUSE/job/tests-on-diff/226/ for more details.

Hmm. Snapshot branch targets are either an alias, or a pointer to a swhid of any type.

This change will break, for instance, for branch targets that are Release objects (look, e.g., at most tags in a SWH git repository), or Content objects (people use that to store GPG keys), or Directory objects (such as some old tags on linux.git).

Might I suggest only special-casing alias branches to make them *relative symlinks* to their target (within the snapshot directory), and keeping the common case symlink to the archive/ directory for other types?

Rework implementation according to olasd comment.

Build is green

Patch application report for D4665 (id=16561)

Rebasing onto f3363d909f...

Current branch diff-target is up to date.
Changes applied before test
commit 9e8325f7396fcaac4d1213849bfbc846901820d6
Author: Thibault Allançon <haltode@gmail.com>
Date:   Fri Dec 4 11:56:17 2020 +0100

    snapshot: add support for 'alias' target type
    
    Fix T2840.

See https://jenkins.softwareheritage.org/job/DFUSE/job/tests-on-diff/227/ for more details.

This looks probably fine, with one caveat inline.

Maybe you should consider adding some more different object types to your snapshot in test fixtures.

swh/fuse/fs/artifact.py
488

I think this only works if you're not in a subdirectory. You should add a test for a branch "refs/heads/alias" pointing at "refs/heads/master" and see whether that really works.

This revision is now accepted and ready to land.Dec 4 2020, 4:32 PM
  • Rework prefix calculation using os.path.relpath()
  • Add custom snapshot data in test to try out multiple special cases

Build is green

Patch application report for D4665 (id=16578)

Rebasing onto f3363d909f...

Current branch diff-target is up to date.
Changes applied before test
commit 77a5bcd6d73d168d05ae5baa5ce9291e36c74df5
Author: Thibault Allançon <haltode@gmail.com>
Date:   Fri Dec 4 11:56:17 2020 +0100

    snapshot: add support for 'alias' target type
    
    Fix T2840.

See https://jenkins.softwareheritage.org/job/DFUSE/job/tests-on-diff/228/ for more details.