From a3cf05c4b3935cb2bfbfedd129bb6dd7690e8130 Mon Sep 17 00:00:00 2001 From: Joachim Jablon Date: Tue, 26 Sep 2023 09:18:52 +0200 Subject: [PATCH] Add better error handling for wrong diff format --- coverage_comment/coverage.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/coverage_comment/coverage.py b/coverage_comment/coverage.py index 87c4dca0..75c43bf9 100644 --- a/coverage_comment/coverage.py +++ b/coverage_comment/coverage.py @@ -288,7 +288,8 @@ def parse_diff_output(diff: str) -> dict[pathlib.Path, list[int]]: current_file = pathlib.Path(line.removeprefix(added_filename_prefix)) continue if line.startswith("@@"): - assert current_file + if current_file is None: + raise ValueError(f"Unexpected diff output format: \n{diff}") lines = parse_line_number_diff_line(line) result.setdefault(current_file, []).extend(lines) continue