Compare commits

...

1 Commits

Author SHA1 Message Date
dgtlmoon
b70020582f Fix - diff_changed_to causing some missed notifications #4063 #3818 2026-04-19 11:53:00 +02:00
2 changed files with 6 additions and 5 deletions

View File

@@ -64,7 +64,7 @@ def extract_changed_from(raw_diff: str) -> str:
Useful for {{diff_changed_from}} — gives just the old value (e.g. old price),
not the full surrounding line. Multiple fragments joined with newlines.
"""
return '\n'.join(m.group(1) or m.group(2) for m in _EXTRACT_REMOVED_RE.finditer(raw_diff))
return '\n'.join(next((g for g in m.groups() if g is not None), '') for m in _EXTRACT_REMOVED_RE.finditer(raw_diff))
def extract_changed_to(raw_diff: str) -> str:
@@ -73,7 +73,7 @@ def extract_changed_to(raw_diff: str) -> str:
Useful for {{diff_changed_to}} — gives just the new value (e.g. new price),
not the full surrounding line. Multiple fragments joined with newlines.
"""
return '\n'.join(m.group(1) or m.group(2) for m in _EXTRACT_ADDED_RE.finditer(raw_diff))
return '\n'.join(next((g for g in m.groups() if g is not None), '') for m in _EXTRACT_ADDED_RE.finditer(raw_diff))
def render_inline_word_diff(before_line: str, after_line: str, ignore_junk: bool = False, markdown_style: str = None, tokenizer: str = 'words_and_html', include_change_type_prefix: bool = True) -> tuple[str, bool]:
@@ -457,8 +457,8 @@ def render_diff(
Returns:
str: Rendered difference
"""
newest_lines = [line.rstrip() for line in newest_version_file_contents.splitlines()]
previous_lines = [line.rstrip() for line in previous_version_file_contents.splitlines()] if previous_version_file_contents else []
newest_lines = [line.rstrip() for line in (newest_version_file_contents or '').splitlines()]
previous_lines = [line.rstrip() for line in (previous_version_file_contents or '').splitlines()]
now = time.time()
logger.debug(
f"diff options: "

View File

@@ -102,7 +102,8 @@ class FormattableExtract(str):
def __new__(cls, prev_snapshot, current_snapshot, extract_fn):
if prev_snapshot or current_snapshot:
from changedetectionio import diff as diff_module
raw = diff_module.render_diff(prev_snapshot, current_snapshot, word_diff=True)
# word_diff=True is required — placemarker extraction regexes only exist in word-diff output
raw = diff_module.render_diff(prev_snapshot or '', current_snapshot or '', word_diff=True)
extracted = extract_fn(raw)
else:
extracted = ''