Skip to content
Snippets Groups Projects
Commit e9839553 authored by Chris Lamb's avatar Chris Lamb :eyes:
Browse files

Continue loading a .changes file if the referenced files do not exist, but...

Continue loading a .changes file if the referenced files do not exist, but include a comment in the returned diff.
parent 63ffe02e
No related branches found
No related tags found
No related merge requests found
Pipeline #311358 passed
......@@ -236,9 +236,12 @@ class DotChangesFile(DebControlFile):
return False
try:
file.validation_msg = None
file._deb822.validate("sha256", check_signature=False)
except FileNotFoundError:
return False
except FileNotFoundError as exc:
# Continue even though this .changes file may be invalid
file.validation_msg = f"{os.path.basename(file.path)} is missing referenced files: {exc}"
logger.warning(file.validation_msg)
return True
......@@ -248,6 +251,10 @@ class DotChangesFile(DebControlFile):
if differences is None:
return None
for x in (self, other):
if x.validation_msg:
differences.add_comment(x.validation_msg)
other_deb822 = self._get_deb822(other)
files = zip(self._deb822.get("Files"), other_deb822.get("Files"))
......
......@@ -113,7 +113,8 @@ def test_dot_changes_invalid(tmpdir):
shutil.copy(TEST_DOT_CHANGES_FILE1_PATH, dot_changes_path)
# we don't copy the referenced .deb
identified = specialize(FilesystemFile(dot_changes_path))
assert not isinstance(identified, DotChangesFile)
# ... but it is identified regardless
assert isinstance(identified, DotChangesFile)
def test_dot_changes_no_differences(dot_changes1):
......
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