Changeset View
Changeset View
Standalone View
Standalone View
swh/web/tests/common/test_identifiers.py
Show First 20 Lines • Show All 550 Lines • ▼ Show 20 Lines | ): | ||||
query_params["snapshot"] = snapshot_id | query_params["snapshot"] = snapshot_id | ||||
if object_type in (CONTENT, DIRECTORY, REVISION): | if object_type in (CONTENT, DIRECTORY, REVISION): | ||||
if snapshot_context["release"]: | if snapshot_context["release"]: | ||||
obj_context["anchor"] = gen_swhid(RELEASE, snapshot_context["release_id"]) | obj_context["anchor"] = gen_swhid(RELEASE, snapshot_context["release_id"]) | ||||
query_params["release"] = snapshot_context["release"] | query_params["release"] = snapshot_context["release"] | ||||
else: | else: | ||||
obj_context["anchor"] = gen_swhid(REVISION, snapshot_context["revision_id"]) | obj_context["anchor"] = gen_swhid(REVISION, snapshot_context["revision_id"]) | ||||
if ( | if object_type != REVISION: | ||||
snapshot_context["branch"] | |||||
and snapshot_context["branch"] != snapshot_context["revision_id"] | |||||
): | |||||
branch = snapshot_context["branch"] | |||||
if branch == "HEAD": | |||||
for b in snapshot_context["branches"]: | |||||
if ( | |||||
b["revision"] == snapshot_context["revision_id"] | |||||
and b["name"] != "HEAD" | |||||
): | |||||
branch = b["name"] | |||||
break | |||||
query_params["branch"] = branch | |||||
elif object_type != REVISION: | |||||
query_params["revision"] = snapshot_context["revision_id"] | query_params["revision"] = snapshot_context["revision_id"] | ||||
if path: | if path: | ||||
obj_context["path"] = path | obj_context["path"] = path | ||||
if path != "/": | if path != "/": | ||||
if object_type == CONTENT: | if object_type == CONTENT: | ||||
query_params["path"] = path[1:] | query_params["path"] = path[1:] | ||||
else: | else: | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |