gitlab: Allow ingestion of hg_git origins as hg ones
Related to T3581#70593
This commit is contained in:
parent
4e4edee478
commit
fdb420238c
2 changed files with 8 additions and 13 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue