fix: repair two pre-existing test failures - #21
Merged
Merged
Conversation
Adds three new capabilities: - `devlog tags [list]` — list all tags with per-day usage counts, sorted by frequency then alphabetically; supports --json for machine-readable output - `devlog tags rename <old> <new>` — rename a tag across all day files with case-insensitive matching, preserving tag order and unaffected files - `Store.AllDates()` — scans the journal dir for YYYY-MM-DD.md files, returns dates sorted oldest-first; reused by both ListTags and RenameTag All functionality written TDD: tests were written first (22 new tests across store and cmd packages) and the implementation written to make them pass. https://claude.ai/code/session_012VD25qMzTC7GEYqYvCPP6Z
Updates CHANGELOG, README, user guide, and AGENT_INSTRUCTIONS to cover the new tags list and tags rename subcommands — including terminal output format, JSON schema, jq patterns, filtering workflow, and key behaviors (case-insensitive match, per-day counts, atomic rename). https://claude.ai/code/session_012VD25qMzTC7GEYqYvCPP6Z
Bug fix: - RenameTag now deduplicates tags after rename, preventing [auth, oauth] + rename auth→oauth from producing [oauth, oauth] Validation: - RenameTag returns an error for empty old or new tag strings New tests (store): - TestRenameTag_NewTagAlreadyPresent — dedup when newTag already in entry - TestRenameTag_NewTagAlreadyPresent_PreservesFirst — first-seen wins after dedup - TestRenameTag_EmptyOldTag / TestRenameTag_EmptyNewTag — empty string guards - TestAllDates_NonExistentDir — non-existent dir returns empty, not error New tests (render): - TestTagsTerminal_Empty / TestTagsTerminal_ShowsTagsAndCounts - TestTagsJSON_EmptySlice / TestTagsJSON_Schema / TestTagsJSON_PreservesInputOrder New tests (cmd): - TestTagsRenameCmd_DeduplicatesWhenNewTagAlreadyPresent - TestTagsRenameCmd_CaseInsensitive https://claude.ai/code/session_012VD25qMzTC7GEYqYvCPP6Z
Tags must now match [a-z0-9_]+ at write time: - devlog add --tag rejects uppercase, hyphens, spaces, and empty strings - devlog tags rename rejects an invalid new tag name (old tag still matched case-insensitively to handle pre-existing legacy tags) Implementation: - store.ValidateTag() — single validation function with compiled regexp - Wired into cmd/add.go (before Modify) and cmd/tags.go (before RenameTag) Tests (TDD — written before implementation): - TestValidateTag_Valid / TestValidateTag_Invalid (9 valid, 8 invalid cases) - TestAddCmd_RejectsUppercaseTag / RejectsHyphenatedTag / RejectsEmptyTag - TestTagsRenameCmd_RejectsInvalidNewTag Docs updated: user-guide.md add section, tags rename section; AGENT_INSTRUCTIONS key behaviors. https://claude.ai/code/session_012VD25qMzTC7GEYqYvCPP6Z
internal/config: TestWrite_AtomicNoPanicOnError The test chmod's a dir to 0500 then expects a write into it to fail. In environments running with elevated privileges the write succeeds, causing a false failure. Added a probe write after chmod; if it succeeds the test is skipped with a clear reason. internal/git: TestGetOriginSlug_* / TestScanCommits_* initTempRepo runs `git commit` in a temp dir, but environments with a mandatory GPG/SSH signing hook hit a signing server that returns 400. Added `git config commit.gpgsign false` scoped to the temp repo so the commit is not subject to the global signing configuration. https://claude.ai/code/session_012VD25qMzTC7GEYqYvCPP6Z
The probe file's Close() error is intentionally ignored (it's a write-permission probe in a test); use _ = f.Close() so errcheck doesn't flag the unchecked return value. https://claude.ai/code/session_012VD25qMzTC7GEYqYvCPP6Z
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
internal/config—TestWrite_AtomicNoPanicOnErrorwas failing in environments with elevated privileges (e.g. root) that bypasschmod 0500. Added a probe write after the chmod; if it succeeds, the test skips with a clear reason instead of failing.internal/git— AllinitTempRepo-based tests (TestGetOriginSlug_*,TestScanCommits_*) were failing because the environment enforces mandatory GPG/SSH commit signing via a server that returns 400 for test repos. Fixed by settingcommit.gpgsign = falselocally on each temp repo — scoped to the test fixture only, no effect on real commits.Neither fix changes production code or weakens what the tests verify. Both are environment adaptations only.
Test plan
go test ./internal/config/...— previously failing test now skips cleanlygo test ./internal/git/...— all 5 previously failing tests now passgo test ./...— full suite greenhttps://claude.ai/code/session_012VD25qMzTC7GEYqYvCPP6Z