diff --git a/swh/web/browse/views/content.py b/swh/web/browse/views/content.py
--- a/swh/web/browse/views/content.py
+++ b/swh/web/browse/views/content.py
@@ -14,7 +14,7 @@
import sentry_sdk
from swh.model.hashutil import hash_to_hex
-from swh.model.identifiers import CONTENT
+from swh.model.identifiers import CONTENT, DIRECTORY, RELEASE, REVISION, SNAPSHOT
from swh.web.browse.browseurls import browse_route
from swh.web.browse.snapshot_context import get_snapshot_context
@@ -343,10 +343,33 @@
origin_url=origin_url,
)
+ swh_objects = [
+ SWHObjectInfo(object_type=CONTENT, object_id=content_checksums["sha1_git"])
+ ]
+
+ if directory_id:
+ swh_objects.append(SWHObjectInfo(object_type=DIRECTORY, object_id=directory_id))
+
+ 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(
- [SWHObjectInfo(object_type=CONTENT, object_id=content_checksums["sha1_git"])],
- snapshot_context,
- extra_context=content_metadata,
+ swh_objects, snapshot_context, extra_context=content_metadata,
)
heading = "Content - %s" % content_checksums["sha1_git"]
diff --git a/swh/web/tests/browse/views/test_content.py b/swh/web/tests/browse/views/test_content.py
--- a/swh/web/tests/browse/views/test_content.py
+++ b/swh/web/tests/browse/views/test_content.py
@@ -10,7 +10,7 @@
from hypothesis import given
-from swh.model.identifiers import CONTENT, DIRECTORY
+from swh.model.identifiers import CONTENT, DIRECTORY, RELEASE, REVISION, SNAPSHOT
from swh.web.browse.snapshot_context import process_snapshot_branches
from swh.web.browse.utils import (
get_mimetype_and_encoding_for_content,
@@ -455,6 +455,45 @@
assert_contains(resp, directory_file["name"])
assert_contains(resp, f"Branch: {branch_info['name']}")
+ cnt_swhid = get_swh_persistent_id(
+ CONTENT,
+ directory_file["checksums"]["sha1_git"],
+ metadata={
+ "origin": origin["url"],
+ "visit": get_swh_persistent_id(SNAPSHOT, snapshot),
+ "anchor": get_swh_persistent_id(REVISION, branch_info["revision"]),
+ "path": f"/{directory_file['name']}",
+ },
+ )
+ assert_contains(resp, cnt_swhid)
+
+ dir_swhid = get_swh_persistent_id(
+ DIRECTORY,
+ directory,
+ 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):
@@ -487,6 +526,55 @@
assert_contains(resp, directory_file["name"])
assert_contains(resp, f"Release: {release_info['name']}")
+ cnt_swhid = get_swh_persistent_id(
+ CONTENT,
+ directory_file["checksums"]["sha1_git"],
+ metadata={
+ "origin": origin["url"],
+ "visit": get_swh_persistent_id(SNAPSHOT, snapshot),
+ "anchor": get_swh_persistent_id(RELEASE, release_info["id"]),
+ "path": f"/{directory_file['name']}",
+ },
+ )
+ assert_contains(resp, cnt_swhid)
+
+ dir_swhid = get_swh_persistent_id(
+ DIRECTORY,
+ release_info["directory"],
+ 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(