diff --git a/swh/web/browse/views/directory.py b/swh/web/browse/views/directory.py
--- a/swh/web/browse/views/directory.py
+++ b/swh/web/browse/views/directory.py
@@ -11,7 +11,7 @@
import sentry_sdk
-from swh.model.identifiers import DIRECTORY
+from swh.model.identifiers import DIRECTORY, RELEASE, REVISION, SNAPSHOT
from swh.web.browse.browseurls import browse_route
from swh.web.browse.snapshot_context import get_snapshot_context
from swh.web.browse.utils import (
@@ -160,6 +160,24 @@
swh_objects = [SWHObjectInfo(object_type=DIRECTORY, object_id=sha1_git)]
+ if snapshot_context:
+ swh_objects.append(
+ SWHObjectInfo(
+ object_type=REVISION, object_id=snapshot_context["revision_id"]
+ )
+ )
+ swh_objects.append(
+ SWHObjectInfo(
+ object_type=SNAPSHOT, object_id=snapshot_context["snapshot_id"]
+ )
+ )
+ if snapshot_context["release_id"]:
+ swh_objects.append(
+ SWHObjectInfo(
+ object_type=RELEASE, object_id=snapshot_context["release_id"]
+ )
+ )
+
swhids_info = get_swhids_info(swh_objects, snapshot_context, dir_metadata)
heading = "Directory - %s" % sha1_git
diff --git a/swh/web/tests/browse/views/test_directory.py b/swh/web/tests/browse/views/test_directory.py
--- a/swh/web/tests/browse/views/test_directory.py
+++ b/swh/web/tests/browse/views/test_directory.py
@@ -9,7 +9,7 @@
from django.utils.html import escape
from hypothesis import given
-from swh.model.identifiers import DIRECTORY
+from swh.model.identifiers import DIRECTORY, RELEASE, REVISION, SNAPSHOT
from swh.web.browse.snapshot_context import process_snapshot_branches
from swh.web.common.identifiers import get_swh_persistent_id
from swh.web.common.utils import gen_path_info, reverse
@@ -106,12 +106,40 @@
)
resp = client.get(url)
+
assert resp.status_code == 200
assert_template_used(resp, "browse/directory.html")
_check_origin_snapshot_related_html(resp, origin, snapshot, branches, releases)
assert_contains(resp, directory_subdir["name"])
assert_contains(resp, f"Branch: {branch_info['name']}")
+ dir_swhid = get_swh_persistent_id(
+ DIRECTORY,
+ directory_subdir["target"],
+ metadata={
+ "origin": origin["url"],
+ "visit": get_swh_persistent_id(SNAPSHOT, snapshot),
+ "anchor": get_swh_persistent_id(REVISION, branch_info["revision"]),
+ "path": "/",
+ },
+ )
+ assert_contains(resp, dir_swhid)
+
+ rev_swhid = get_swh_persistent_id(
+ REVISION,
+ branch_info["revision"],
+ metadata={
+ "origin": origin["url"],
+ "visit": get_swh_persistent_id(SNAPSHOT, snapshot),
+ },
+ )
+ assert_contains(resp, rev_swhid)
+
+ snp_swhid = get_swh_persistent_id(
+ SNAPSHOT, snapshot, metadata={"origin": origin["url"],},
+ )
+ assert_contains(resp, snp_swhid)
+
@given(origin_with_multiple_visits())
def test_content_origin_snapshot_release_browse(client, archive_data, origin):
@@ -145,6 +173,43 @@
assert_contains(resp, directory_subdir["name"])
assert_contains(resp, f"Release: {release_info['name']}")
+ dir_swhid = get_swh_persistent_id(
+ DIRECTORY,
+ directory_subdir["target"],
+ metadata={
+ "origin": origin["url"],
+ "visit": get_swh_persistent_id(SNAPSHOT, snapshot),
+ "anchor": get_swh_persistent_id(RELEASE, release_info["id"]),
+ "path": "/",
+ },
+ )
+ assert_contains(resp, dir_swhid)
+
+ rev_swhid = get_swh_persistent_id(
+ REVISION,
+ release_info["target"],
+ metadata={
+ "origin": origin["url"],
+ "visit": get_swh_persistent_id(SNAPSHOT, snapshot),
+ },
+ )
+ assert_contains(resp, rev_swhid)
+
+ rel_swhid = get_swh_persistent_id(
+ RELEASE,
+ release_info["id"],
+ metadata={
+ "origin": origin["url"],
+ "visit": get_swh_persistent_id(SNAPSHOT, snapshot),
+ },
+ )
+ assert_contains(resp, rel_swhid)
+
+ snp_swhid = get_swh_persistent_id(
+ SNAPSHOT, snapshot, metadata={"origin": origin["url"],},
+ )
+ assert_contains(resp, snp_swhid)
+
def _check_origin_snapshot_related_html(resp, origin, snapshot, branches, releases):
browse_origin_url = reverse(