summaryrefslogtreecommitdiff
path: root/lib/notes.source.sh
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-01 17:35:16 +0200
committerPaul Buetow <paul@buetow.org>2026-03-01 17:35:16 +0200
commitfc063aba4822e8e7d9ccc6c721fc2a711298e166 (patch)
treec42656f6db4fe10e1dc4ee8d585c974d7a323f82 /lib/notes.source.sh
parent00e5de525bde5d0d77d9553c6126908f2fdfde20 (diff)
Extract generate::safe_overwrite helper to eliminate DRY violation
The "safe overwrite" pattern (diff -q tmp dest, then rm or mv) was duplicated in template, gemfeed (2x), and notes modules. Extracted into a shared helper with unit tests covering all three cases (no dest, identical dest, differing dest). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'lib/notes.source.sh')
-rw-r--r--lib/notes.source.sh6
1 files changed, 1 insertions, 5 deletions
diff --git a/lib/notes.source.sh b/lib/notes.source.sh
index 85bd2b5..08af3e5 100644
--- a/lib/notes.source.sh
+++ b/lib/notes.source.sh
@@ -42,9 +42,5 @@ That were all notes. Hope they were useful!
NOTES
# Only overwrite if content changed, preserving mtime for template skip logic
- if [[ -f "$notes_dir/index.gmi" ]] && diff -q "$notes_dir/index.gmi.tmp" "$notes_dir/index.gmi" >/dev/null 2>&1; then
- rm "$notes_dir/index.gmi.tmp"
- else
- mv "$notes_dir/index.gmi.tmp" "$notes_dir/index.gmi"
- fi
+ generate::safe_overwrite "$notes_dir/index.gmi.tmp" "$notes_dir/index.gmi"
}