Stage the translations before checking for changes - #15
Merged
Conversation
The GitLab recipe printed by `init` ran `git diff --quiet` before `git add -A`. On the first run the translations are new files, which a plain `git diff` does not look at, so the check reported nothing to do: the job skipped the push and went green without opening a merge request. A second run worked, because by then the files were tracked — so the failure landed on the one run where a user is deciding whether this works at all. The recipe now stages first and checks `git diff --cached --quiet`, which is what the snippet published in the product already does. The self-test asserts the order rather than the presence of both commands, and fails on the previous revision.
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.
initprints a GitLab job whose last step commits the downloaded translations and pushes them as a merge request. That step askedgit diff --quietbefore it rangit add -A.On the first run the translations are new files. A plain
git diffcompares the worktree against the index and only looks at tracked paths, so it reports nothing to do: the block is skipped, no branch is pushed, no merge request appears — and the job still ends green. A second run works, because by then the files are tracked. So the failure lands on exactly the run where someone is deciding whether this works at all.Reproduced before the change: with an untracked file present and nothing else modified,
git diff --quietexits 0.The job now stages first and asks
git diff --cached --quiet, which is what the snippet published in the product already does — the two copies of this recipe had drifted apart.Verification
tests/test-init.sh: 75 assertions, 0 failures. The three new ones fail againstmain: they assert the order (git add -Abefore the check), the--cachedform, and the absence of the worktree-only check, so a revert cannot pass them silently.bash -n ptc-cli.shis clean.