Skip to content
Snippets Groups Projects
Commit 9868dcbc authored by Antoine Lambert's avatar Antoine Lambert
Browse files

debian: Handle invalid version string when parsing changelog

Some packages can have an invalid version string in their changelog
which raises a ValueError when attempting to parse it in the
get_intrinsic_package_metadata method of the loader.

As a consequence each package release with such bogus entry in the
changelog was discarded from the snapshot created by the loader.

So prefer to get the raw string version instead of parsing it to
workaround that issue.

Fix #1493.
parent f41a28d1
No related branches found
No related tags found
1 merge request!460debian: Handle invalid version string when parsing changelog
Pipeline #1893 passed
......@@ -446,8 +446,8 @@ def get_intrinsic_package_metadata(
history: List[Tuple[str, str]] = []
for block in parsed_changelog:
assert block.package is not None
history.append((block.package, str(block.version)))
assert block.package is not None and block._raw_version is not None
history.append((block.package, block._raw_version))
changelog = DebianPackageChangelog(
person=uid_to_person(parsed_changelog.author),
......
......@@ -8,6 +8,7 @@ import datetime
import hashlib
import logging
from os import path
import textwrap
import pytest
import requests
......@@ -433,6 +434,21 @@ def test_debian_get_intrinsic_package_metadata(
# Retrieve information on package
dsc_path = path.join(path.dirname(extracted_path), dsc_name)
with open(path.join(extracted_path, "debian/changelog"), "a") as changelog:
# Add a changelog entry with an invalid version string
changelog.write(
textwrap.dedent(
"""
cicero (0.7-1_cvs) unstable; urgency=low
* Initial release
-- John Doe <john.doe@example.org> Tue, 12 Sep 2006 10:20:09 +0200
"""
)
)
actual_package_info = get_intrinsic_package_metadata(
p_info, dsc_path, extracted_path
)
......@@ -446,6 +462,7 @@ def test_debian_get_intrinsic_package_metadata(
("cicero", "0.7.2-2"),
("cicero", "0.7.2-1"),
("cicero", "0.7-1"),
("cicero", "0.7-1_cvs"),
],
person={
"email": "sthibault@debian.org",
......
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