Skip to content
Snippets Groups Projects
Commit 968ddef2 authored by Franck Bret's avatar Franck Bret
Browse files

Improve registry repository management

Ensure the registry path does not exists before cloning the repository.
parent 360fa753
No related branches found
No related tags found
1 merge request!489Add Julia Lister for listing Julia Packages
Pipeline #4665 failed
......@@ -33,7 +33,7 @@ class JuliaLister(StatelessLister[JuliaListerPage]):
REPO_URL = (
"https://github.com/JuliaRegistries/General.git" # Julia General Registry
)
REPO_PATH = Path(tempfile.mkdtemp("General"))
REPO_PATH = Path(tempfile.mkdtemp(), "General")
REGISTRY_PATH = REPO_PATH / "Registry.toml"
def __init__(
......@@ -58,10 +58,10 @@ class JuliaLister(StatelessLister[JuliaListerPage]):
def get_registry_repository(self) -> None:
"""Get Julia General Registry Git repository up to date on disk"""
if self.REPO_PATH.exists():
porcelain.pull(self.REPO_PATH, remote_location=self.url)
else:
try:
porcelain.clone(source=self.url, target=self.REPO_PATH)
except FileExistsError:
porcelain.pull(self.REPO_PATH, remote_location=self.url)
def get_pages(self) -> Iterator[JuliaListerPage]:
"""Yield an iterator which returns 'page'
......
......@@ -14,6 +14,24 @@ expected_origins = [
]
def test_julia_get_registry_repository(datadir, tmp_path, swh_scheduler):
archive_path = Path(datadir, "fake-julia-registry-repository.tar.gz")
repo_url = prepare_repository_from_archive(archive_path, "General", tmp_path)
lister = JuliaLister(url=repo_url, scheduler=swh_scheduler)
assert not lister.REPO_PATH.exists()
lister.get_registry_repository()
assert lister.REPO_PATH.exists()
# ensure get_registry_repository is idempotent
lister.get_registry_repository()
assert lister.REPO_PATH.exists()
# ensure the repository is deleted once the lister has run
lister.run()
assert not lister.REPO_PATH.exists()
def test_julia_lister(datadir, tmp_path, swh_scheduler):
archive_path = Path(datadir, "fake-julia-registry-repository.tar.gz")
repo_url = prepare_repository_from_archive(archive_path, "General", tmp_path)
......
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