From 45bbc29a52243a31149610ffa2829afd5a35ae24 Mon Sep 17 00:00:00 2001
From: "Antoine R. Dumont (@ardumont)" <ardumont@softwareheritage.org>
Date: Tue, 21 Mar 2023 12:22:07 +0100
Subject: [PATCH] cgit/tasks: Allow passing extra parameters to task

This unifies with other lister tasks modules. And this allow the cgit task to
be scheduled by the add-forge-now scheduler cli.

Refs. swh/infra/sysadm-environment#4813
---
 swh/lister/cgit/tasks.py            | 12 ++++--------
 swh/lister/cgit/tests/test_tasks.py |  6 ++++--
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/swh/lister/cgit/tasks.py b/swh/lister/cgit/tasks.py
index 9a956489..e912a4df 100644
--- a/swh/lister/cgit/tasks.py
+++ b/swh/lister/cgit/tasks.py
@@ -1,8 +1,8 @@
-# Copyright (C) 2019-2021 The Software Heritage developers
+# Copyright (C) 2019 The Software Heritage developers
 # License: GNU General Public License version 3, or any later version
 # See top-level LICENSE file for more information
 
-from typing import Dict, Optional
+from typing import Dict
 
 from celery import shared_task
 
@@ -10,13 +10,9 @@ from .lister import CGitLister
 
 
 @shared_task(name=__name__ + ".CGitListerTask")
-def list_cgit(
-    url: str, instance: Optional[str] = None, base_git_url: Optional[str] = None
-) -> Dict[str, str]:
+def list_cgit(**lister_args) -> Dict[str, str]:
     """Lister task for CGit instances"""
-    lister = CGitLister.from_configfile(
-        url=url, instance=instance, base_git_url=base_git_url
-    )
+    lister = CGitLister.from_configfile(**lister_args)
     return lister.run().dict()
 
 
diff --git a/swh/lister/cgit/tests/test_tasks.py b/swh/lister/cgit/tests/test_tasks.py
index ce08c696..2c95ee3c 100644
--- a/swh/lister/cgit/tests/test_tasks.py
+++ b/swh/lister/cgit/tests/test_tasks.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2019-2021 The Software Heritage developers
+# Copyright (C) 2019 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
@@ -22,7 +22,9 @@ def test_cgit_lister_task(
     lister.from_configfile.return_value = lister
     lister.run.return_value = ListerStats(pages=10, origins=500)
 
-    kwargs = dict(url="https://git.kernel.org/", instance="kernel", base_git_url=None)
+    kwargs = dict(
+        url="https://git.kernel.org/", instance="kernel", base_git_url=None, max_pages=1
+    )
 
     res = swh_scheduler_celery_app.send_task(
         "swh.lister.cgit.tasks.CGitListerTask",
-- 
GitLab