Skip to content

bugfix(journal): only YYYY-MM-DD.md files count as entries#15

Open
CryptoJones wants to merge 1 commit into
mainfrom
bugfix/journal-only-dated-entries
Open

bugfix(journal): only YYYY-MM-DD.md files count as entries#15
CryptoJones wants to merge 1 commit into
mainfrom
bugfix/journal-only-dated-entries

Conversation

@CryptoJones
Copy link
Copy Markdown
Owner

`_list` and `_show_latest` previously globbed every .md file in
`planning/journal/`, with a hardcoded README.md exclusion. Any other
file the operator dropped in — notes.md, ideas.md, drafts/, a
zzz.md decoy — got listed/shown as if it were a daily entry.

Worse for `--show`: alphabetical sorting put zzz.md after every real
dated entry, so `socrates journal --show` would print the wrong
file (whatever happened to sort last).

Fix: introduce `_is_journal_entry` that requires the stem to match
^\d{4}-\d{2}-\d{2}$ (canonical ISO date). Used by both `_list`
and `_show_latest`. Also pinned encoding="utf-8" on the show
read_text (matching the localization fix elsewhere).

Tests added (2):

  • --list shows only 2025-09-01.md and 2026-01-15.md when notes.md,
    ideas.md, and an unpadded 2025-9-1.md are also present.
  • --show picks 2026-06-15.md as the latest, NOT zzz.md (alphabetical
    decoy that would otherwise sort last).

149/149 tests pass; ruff + mypy clean.

Self-review caveat: regex matches 9999-99-99.md (impossible date). _dt.date.fromisoformat would reject it downstream but --list still prints it. Cosmetic.

\`_list\` and \`_show_latest\` previously globbed every .md file in
\`planning/journal/\`, with a hardcoded README.md exclusion. Any other
file the operator dropped in — notes.md, ideas.md, drafts/, a
zzz.md decoy — got listed/shown as if it were a daily entry.

Worse for \`--show\`: alphabetical sorting put zzz.md after every real
dated entry, so \`socrates journal --show\` would print the wrong
file (whatever happened to sort last).

Fix: introduce \`_is_journal_entry\` that requires the stem to match
^\\d{4}-\\d{2}-\\d{2}$ (canonical ISO date). Used by both \`_list\`
and \`_show_latest\`. Also pinned encoding="utf-8" on the show
read_text (matching the localization fix elsewhere).

Tests added (2):
- --list shows only 2025-09-01.md and 2026-01-15.md when notes.md,
  ideas.md, and an unpadded 2025-9-1.md are also present.
- --show picks 2026-06-15.md as the latest, NOT zzz.md (alphabetical
  decoy that would otherwise sort last).

149/149 tests pass; ruff + mypy clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant