fix(diff): check modified count in identical-files guard#792
fix(diff): check modified count in identical-files guard#792gghez wants to merge 1 commit intortk-ai:developfrom
Conversation
📊 Automated PR Analysis
SummaryFixes a bug where Review Checklist
Linked issues: #781 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
|
Hey We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes No logic changes — only file moves and import path updates. What you need to doRebase your branch on git fetch origin && git rebase origin/developGit detects renames automatically. If you get import conflicts, update the paths: use crate::git; // now: use crate::cmds::git::git;
use crate::tracking; // now: use crate::core::tracking;
use crate::config; // now: use crate::core::config;
use crate::init; // now: use crate::hooks::init;
use crate::gain; // now: use crate::analytics::gain;Need help rebasing? Tag @aeppling |
The "Files are identical" check only tested added and removed counters, ignoring modified lines. When two lines shared enough characters to be classified as a modification (similarity > 0.5), they incremented modified but not added/removed, so the guard passed and the diff reported no changes. Also replace the Jaccard set-based similarity function with a positional prefix+suffix metric that better reflects actual line differences — the old approach used unique character sets, which over-estimated similarity for lines sharing common characters in different positions. Fixes rtk-ai#781 Signed-off-by: gghez <gghez@users.noreply.github.com>
a82ce04 to
6ea71e5
Compare
|
Done, rebased on develop. Had a small conflict in the test section since both branches added tests at the end of |
Summary
rtk diffincorrectly reports "Files are identical" when lines differ by only a few characters. Two root causes:The identical-files guard at line 24 only checked
added == 0 && removed == 0, ignoring themodifiedcounter. Lines classified as modifications (similarity > 0.5) incrementedmodifiedbut notadded/removed, so the guard passed and the diff silently swallowed actual differences.The
similarity()function used Jaccard similarity on unique character sets, which over-estimated similarity for lines sharing common characters regardless of position. Replaced it with a positional prefix+suffix ratio that better reflects actual line differences.Changes
&& diff.modified == 0to the identical-files guard inrun()similarity()implementation: Jaccard set-based -> positional prefix+suffix metrictest_similarity_partial_overlapfor the new metricTest plan
cargo test --all)diffreports "Files are identical" when lines differ by only a few characters #781cargo checkcompiles without warningsFixes #781