fix(sync): let auto-commit recognise its own translation output - #112
Open
sjsyrek wants to merge 1 commit into
Open
fix(sync): let auto-commit recognise its own translation output#112sjsyrek wants to merge 1 commit into
sjsyrek wants to merge 1 commit into
Conversation
Auto-commit treated only the files a given run wrote as its own, which broke in two directions. A translation left on disk by an earlier refused run was classed as an unrelated modification, so every later run refused for the presence of a file auto-commit had itself produced. The only way out was committing it by hand. In --watch mode the same path runs once per trigger, and the checks were skipped entirely when a trigger translated nothing. That reported success while a commit was still owed: no commit made, the translation uncommitted and the tree still dirty. Ownership is now derived from the lockfile's tracked source files, each matched to its own bucket by include glob so one bucket's target_path_pattern cannot claim another bucket's output. Staging follows what is actually dirty rather than what the run claims it wrote, so a rewrite producing identical bytes no longer attempts an empty commit, and a cycle with nothing to commit stays silent. The unit tests mocked git as reporting a clean tree while also asserting that files had just been written — a state git cannot produce. They now present the working tree their scenario implies. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <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
deepl sync --auto-committreated only the files a given run wrote as its own. That broke in two directions, and both are fixed by deriving ownership from the sync's configured targets instead.A translation left behind by an earlier refusal was never committable. A refused run still writes its translations to disk. On the next run that file was classed as an unrelated modification — so auto-commit refused because of a file it had produced itself, and kept refusing. The only escape was committing it by hand.
In
--watchmode a trigger that translated nothing reported success while a commit was still owed. The same path runs once per trigger, and the checks were gated on that run having written files. When a trigger found nothing to translate, the checks were skipped entirely: no commit made, the translation still uncommitted, the tree still dirty, and no error.Changes Made
target_localesvia the existingresolveTargetPath. Each source file is matched to its own bucket by include glob, so one bucket'starget_path_patterncannot claim another bucket's output.fileResults.length > 0gate is removed from the watch path, matching the one-shot path. A cycle with nothing to commit is now silent rather than skipped-but-reported-successful.Test Coverage
269 suites / 6098 tests green; lint and type-check clean.
Two new integration tests against a real git repo:
The unit tests needed correcting rather than adapting: they mocked git as reporting a clean tree while simultaneously asserting that files had just been written — a state git cannot produce. Each now presents the working tree its scenario implies, which is why several of them moved.
Backward Compatibility
✅ No API or flag changes.
Size: Small ✓
One source file plus tests. The risk sits in the ownership derivation, which is covered by the two integration tests above running against real git rather than a mock.
🤖 Generated with Claude Code