Flag whether each duplicate's content matches the note being kept - #124
Conversation
The listing said which notes would be deleted but not whether anything would be lost. The notes are already decrypted locally by the sync, so comparing them costs nothing. Each note to be deleted is now labelled identical or differs, comparing its title and text with the note being kept. --identical-only restricts deletion to exact copies and reports the rest. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 22 |
| Duplication | 6 |
🟢 Coverage 38.18% diff coverage · +0.14% coverage variation
Metric Results Coverage variation ✅ +0.14% coverage variation (-1.00%) Diff coverage ✅ 38.18% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (76ab438) 9037 973 10.77% Head commit (c146727) 9082 (+45) 991 (+18) 10.91% (+0.14%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#124) 55 21 38.18% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The command can print a misleading “no duplicate notes found” message after reporting kept-differing/kept-no-original duplicates, which should be clarified for correct UX.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
What changed in this PR
This PR enhances sn delete duplicates to show whether each duplicate note’s content matches the note being kept, and adds an --identical-only option to delete only exact copies (same title + text) while reporting notes that differ.
Changes:
- Add content comparison (
Identical) to duplicate summaries and displayidentical/differsin the duplicates listing. - Introduce
--identical-onlyto delete only exact copies and keep/report diverged duplicates. - Extend tests to cover identical/differing content and the new filter behavior.
| File | Description |
|---|---|
README.md |
Documents the new “identical vs differs” listing and --identical-only usage. |
internal/sncli/duplicates.go |
Computes Identical per deletion candidate and implements KeepOnlyIdentical + config/output plumbing. |
internal/sncli/duplicates_test.go |
Adds coverage for identical/differing content and KeepOnlyIdentical filtering. |
cmd/sncli/duplicates.go |
Wires CLI flag into the command, prints content labels, and reports notes kept due to differing content. |
cmd/sncli/delete.go |
Adds shell completion + CLI flag definition for --identical-only. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| writeDuplicatesKept(c, found.KeptNoOriginal) | ||
| writeDuplicatesDiffering(c, found.KeptDiffering) | ||
|
|
||
| toDelete := found.Deleted() | ||
|
|

Follow-up to #120 and #121.
Why
The listing said which notes would be deleted, but not whether deleting them would lose anything. Notes are already decrypted locally by the sync the command performs, so comparing their content costs nothing: no extra API calls.
What changed
Every note about to be deleted is now labelled by comparing its title and text with the note being kept:
--identical-onlydeletes just the exact copies and reports the rest, so a note edited since it was duplicated is left for you to look at:Default behaviour is unchanged: without the flag, every note in the set is still deleted apart from the newest.
A note whose text matches but whose title doesn't counts as
differs, since something was changed after the copy was made.Tests
Five new cases: identical content, differing text, differing title, the
--identical-onlyfilter including a set where nothing is identical and the whole set is dropped, and the filter on an empty input. Sixteen tests in total for this command.make lintreports 0 issues andmake testpasses.Still not tested against a real account — no credentials here, so only the selection and comparison logic is covered.
🤖 Generated with Claude Code