diff --git a/swh/loader/git/tasks.py b/swh/loader/git/tasks.py --- a/swh/loader/git/tasks.py +++ b/swh/loader/git/tasks.py @@ -12,6 +12,15 @@ from swh.loader.git.loader import GitLoader +@shared_task(name=f"save_code_now:{__name__}.UpdateGitRepository") +def load_git_high(*, url: str, base_url: Optional[str] = None) -> Dict[str, Any]: + """Import a git repository from a remote location + + """ + loader = GitLoader.from_configfile(url=url, base_url=base_url) + return loader.load() + + @shared_task(name=__name__ + ".UpdateGitRepository") def load_git(*, url: str, base_url: Optional[str] = None) -> Dict[str, Any]: """Import a git repository from a remote location diff --git a/swh/loader/git/tests/test_tasks.py b/swh/loader/git/tests/test_tasks.py --- a/swh/loader/git/tests/test_tasks.py +++ b/swh/loader/git/tests/test_tasks.py @@ -1,4 +1,4 @@ -# Copyright (C) 2018-2020 The Software Heritage developers +# Copyright (C) 2018-2021 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information @@ -21,6 +21,24 @@ mock_loader.assert_called_once_with() +def test_git_loader_high( + mocker, swh_config, swh_scheduler_celery_app, swh_scheduler_celery_worker +): + mock_loader = mocker.patch("swh.loader.git.loader.GitLoader.load") + mock_loader.return_value = {"status": "eventful"} + + res = swh_scheduler_celery_app.send_task( + "save_code_now:swh.loader.git.tasks.UpdateGitRepository", + kwargs={"url": "origin_url",}, + ) + assert res + res.wait() + assert res.successful() + + assert res.result == {"status": "eventful"} + mock_loader.assert_called_once_with() + + def test_git_loader_from_disk( mocker, swh_config, swh_scheduler_celery_app, swh_scheduler_celery_worker ):