diff --git a/swh/web/browse/snapshot_context.py b/swh/web/browse/snapshot_context.py
--- a/swh/web/browse/snapshot_context.py
+++ b/swh/web/browse/snapshot_context.py
@@ -543,7 +543,6 @@
url=None,
)
)
- branch_name = revision_id
query_params["revision"] = revision_id
elif snapshot_total_size and release_name:
release = _get_release(releases, release_name, snapshot_id)
diff --git a/swh/web/templates/includes/top-navigation.html b/swh/web/templates/includes/top-navigation.html
--- a/swh/web/templates/includes/top-navigation.html
+++ b/swh/web/templates/includes/top-navigation.html
@@ -9,7 +9,7 @@
{% if snapshot_context %}
- {% if snapshot_context.branch or snapshot_context.release %}
+ {% if snapshot_context.branch or snapshot_context.release or snapshot_context.revision_id %}
{% if snapshot_context.branch %}
@@ -19,13 +19,15 @@
{% endif %}
Branch: {{ snapshot_context.branch }}
- {% else %}
+ {% elif snapshot_context.release %}
{% if snapshot_context.release_alias %}
{% else %}
{% endif %}
Release: {{ snapshot_context.release }}
+ {% elif snapshot_context.revision_id %}
+ Revision: {{ snapshot_context.revision_id }}
{% endif %}
diff --git a/swh/web/tests/browse/test_snapshot_context.py b/swh/web/tests/browse/test_snapshot_context.py
--- a/swh/web/tests/browse/test_snapshot_context.py
+++ b/swh/web/tests/browse/test_snapshot_context.py
@@ -362,7 +362,7 @@
)
expected_revision = dict(base_expected_context)
- expected_revision["branch"] = revision["id"]
+ expected_revision["branch"] = None
expected_revision["branch_alias"] = False
expected_revision["branches"] = branches
expected_revision["revision_id"] = revision["id"]
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
@@ -264,7 +264,7 @@
@given(origin_with_multiple_visits())
-def test_content_origin_snapshot_release_browse(client, archive_data, origin):
+def test_drectory_origin_snapshot_release_browse(client, archive_data, origin):
visits = archive_data.origin_visit_get(origin["url"])
visit = random.choice(visits)
snapshot = archive_data.snapshot_get(visit["snapshot"])
@@ -337,6 +337,38 @@
assert_contains(resp, snp_swhid)
+@given(origin_with_multiple_visits())
+def test_directory_origin_snapshot_revision_browse(client, archive_data, origin):
+ visits = archive_data.origin_visit_get(origin["url"])
+ visit = random.choice(visits)
+ snapshot = archive_data.snapshot_get(visit["snapshot"])
+ branches, releases, _ = process_snapshot_branches(snapshot)
+ branch_info = random.choice(branches)
+
+ directory = archive_data.revision_get(branch_info["revision"])["directory"]
+ directory_content = archive_data.directory_ls(directory)
+ directory_subdir = random.choice(
+ [e for e in directory_content if e["type"] == "dir"]
+ )
+
+ url = reverse(
+ "browse-directory",
+ url_args={"sha1_git": directory},
+ query_params={
+ "origin_url": origin["url"],
+ "snapshot": snapshot["id"],
+ "revision": branch_info["revision"],
+ "path": directory_subdir["name"],
+ },
+ )
+
+ resp = check_html_get_response(
+ client, url, status_code=200, template_used="browse/directory.html"
+ )
+
+ assert_contains(resp, f"Revision: {branch_info['revision']} ")
+
+
def _check_origin_snapshot_related_html(
resp, origin, snapshot, snapshot_sizes, branches, releases
):