Skip to content
Snippets Groups Projects
Commit 9c846cd6 authored by vlorentz's avatar vlorentz Committed by Phabricator Migration user
Browse files

Allow cooking release objects via the API

No snapshots yet; they are very costly to cook when swh-graph is
outdated; and currently it is outdated for many objects.
parent 45df1f6e
No related tags found
No related merge requests found
......@@ -404,10 +404,10 @@ def api_vault_cook_git_bare(request, swhid):
.. http:get:: /api/1/vault/git-bare/(swhid)/
.. http:post:: /api/1/vault/git-bare/(swhid)/
Request the cooking of a git-bare archive for a revision or check
its cooking status.
Request the cooking of a git-bare archive for a revision/release
object, or check its cooking status.
That endpoint enables to create a vault cooking task for a revision
That endpoint enables to create a vault cooking task for an object
through a POST request or check the status of a previously created one
through a GET request.
......@@ -415,17 +415,18 @@ def api_vault_cook_git_bare(request, swhid):
can be downloaded using the dedicated endpoint
:http:get:`/api/1/vault/git-bare/(swhid)/raw/`.
Then to import the revision in the current directory, use::
Then to import the object in the current directory, use::
$ tar -xf path/to/swh_1_rev_*.git.tar
$ git clone swh:1:rev:*.git new_repository
(replace ``swh:1:rev:*`` with the SWHID of the requested revision)
(replace ``swh:1:rev:*`` with the SWHID of the requested object)
This will create a directory called ``new_repository``, which is a git
repository containing the requested objects.
:param string swhid: the revision's permanent identifier
:param string swhid: the object's permanent identifier, which should start
with ``swh:1:rev:`` or ``swh:1:rel:``.
:query string email: e-mail to notify when the git-bare archive is ready
......@@ -441,12 +442,12 @@ def api_vault_cook_git_bare(request, swhid):
:>json string swhid: the identifier of the object to cook
:statuscode 200: no error
:statuscode 404: requested directory did not receive any cooking
:statuscode 404: requested object did not receive any cooking
request yet (in case of GET) or can not be found in the archive
(in case of POST)
"""
swhid = CoreSWHID.from_string(swhid)
if swhid.object_type == ObjectType.REVISION:
if swhid.object_type in (ObjectType.REVISION, ObjectType.RELEASE):
res = _dispatch_cook_progress(request, "git_bare", swhid)
res["fetch_url"] = reverse(
"api-1-vault-fetch-git-bare",
......@@ -465,7 +466,9 @@ def api_vault_cook_git_bare(request, swhid):
"Use `/api/1/vault/flat/` to cook directories, as flat bundles."
)
else:
raise BadInputExc("Only revisions can be cooked as 'git-bare' bundles.")
raise BadInputExc(
"Only revisions and releases can be cooked as 'git-bare' bundles."
)
@api_route(
......
......@@ -21,13 +21,14 @@ from swh.web.tests.utils import (
# Current API:
def test_api_vault_cook(api_client, mocker, directory, revision):
def test_api_vault_cook(api_client, mocker, directory, revision, release):
mock_archive = mocker.patch("swh.web.api.views.vault.archive")
for bundle_type, swhid, content_type, in (
("flat", f"swh:1:dir:{directory}", "application/gzip"),
("gitfast", f"swh:1:rev:{revision}", "application/gzip"),
("git_bare", f"swh:1:rev:{revision}", "application/x-tar"),
("git_bare", f"swh:1:rel:{release}", "application/x-tar"),
):
swhid = CoreSWHID.from_string(swhid)
......@@ -154,7 +155,6 @@ def test_api_vault_cook_error_content(api_client, mocker, bundle_type):
("gitfast", "rel", False),
("gitfast", "snp", False),
("git_bare", "dir", True),
("git_bare", "rel", False),
("git_bare", "snp", False),
],
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment