Repository navigation
fix(pull): keep an unstaged edit that git status lists first - #113
Closed
dhruva-vapi wants to merge 1 commit into
Closed
dhruva-vapi wants to merge 1 commit into
dhruva-vapi wants to merge 1 commit into
Conversation
Pull asks git which files were changed locally and reads each record of `git status --porcelain -z` as "XY <path>". The helper trimmed git's output first. An unstaged change is " M <path>", so when it was the first record the trim removed its leading space and the path lost its first letter. Pull then did not treat that file as edited, and in a clone with no baselines it wrote the platform's copy over the edit without saying so. A staged edit, or an unstaged edit that was not first in git's list, was read correctly. gitCmd() now returns git's output as git wrote it. Its other two callers only check that the command succeeds. tests/pull-first-status-record.test.ts covers it: two unstaged edits, and one unstaged edit beside a new untracked file, each with a control. Without the change it fails 2 of 4; with it, 4 of 4. Part of PRISM-2765 Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Contributor
Author
|
Replaced by #114 (same commit, opened as the Devin bot so it can be approved) |
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.

Value
V.A.L.U.E. tier: micro. One line in the engine and one test file.
npm run pullcould overwrite a local edit without saying so. It happened to the first file git lists as changed, when that change was not staged, on a machine with no baselines for the org (a new clone, a new laptop). The person lost the edit andapplythen pushed nothing for that file.pullorapplybefore staging.What's in it
git status --porcelain -zas two status letters, a space and the path. The helper that runs git trimmed the output first. An unstaged change starts with a space, so the first record lost it and its path lost its first letter (esources/<org>/…). That path matched no resource file, and pull treated the file as untouched.tests/pull-first-status-record.test.tsrunspullin a fresh clone against a local server: two unstaged edits, and one unstaged edit beside a new untracked file, each with a control (staged edits, and an edit that is not first in git's list).Verification
npm run build(tsc) passes. Nine other pull and sandbox test files pass when run one at a time with the change.Things to know
git statusin a similar way to tag files as modified. That read only decides what is shown, and it is not changed here.Part of PRISM-2765