Skip to content
Snippets Groups Projects
Verified Commit fdb42023 authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

gitlab: Allow ingestion of hg_git origins as hg ones

Related to T3581#70593
parent 4e4edee4
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,8 @@ from swh.scheduler.model import ListedOrigin
logger = logging.getLogger(__name__)
IGNORED_DVCS = ("hg_git",)
# Some instance provides hg_git type which can be ingested as hg origins
VCS_MAPPING = {"hg_git": "hg"}
@dataclass
......@@ -207,15 +208,10 @@ class GitLabLister(Lister[GitLabListerState, PageResult]):
repositories = page_result.repositories if page_result.repositories else []
for repo in repositories:
visit_type = repo.get("vcs_type", "git")
url = repo["http_url_to_repo"]
if visit_type in IGNORED_DVCS:
logger.warning(
"Ignoring origin %s with type '%s'", url, visit_type,
)
continue
visit_type = VCS_MAPPING.get(visit_type, visit_type)
yield ListedOrigin(
lister_id=self.lister_obj.id,
url=url,
url=repo["http_url_to_repo"],
visit_type=visit_type,
last_update=iso8601.parse_date(repo["last_activity_at"]),
)
......
......@@ -12,7 +12,7 @@ import pytest
from requests.status_codes import codes
from swh.lister import USER_AGENT
from swh.lister.gitlab.lister import IGNORED_DVCS, GitLabLister, _parse_id_after
from swh.lister.gitlab.lister import GitLabLister, _parse_id_after
from swh.lister.pattern import ListerStats
from swh.lister.tests.test_utils import assert_sleep_calls
from swh.lister.utils import WAIT_EXP_BASE
......@@ -69,11 +69,10 @@ def test_lister_gitlab_heptapod(datadir, swh_scheduler, requests_mock):
)
listed_result = lister.run()
expected_nb_origins = 0
expected_nb_origins = len(response)
for entry in response:
if entry["vcs_type"] in IGNORED_DVCS:
continue
expected_nb_origins += 1
assert entry["vcs_type"] in ("hg", "hg_git")
assert listed_result == ListerStats(pages=1, origins=expected_nb_origins)
......
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