[recipes:update] Fixing bug where files failed to delete that were modified previously #895
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.
Hi!
This fixes TWO
recipes:updatebugs:Bug 1️⃣ : sometimes deleted files caused patch to fail
Small bug fix. The mystery is how I didn't catch this before... and how nobody seems to have hit this. The problem is fairly simple:
A) The user gets a file (a long time ago) from a recipe (e.g.
config/bootstrap.php).B) The user modifies (and commits) some change.
C) A recipe update deletes that file.
This, oddly, fails because the patch can't be applied. For example, when
config/packages/dev/framework.yamlis deleted insymfony/framework-bundlerecipe, this patch is correctly generatedHowever, if the user's
framework.yamldoesn't look EXACTLY like this, the patch will fail (not with a conflict like you might expect, it just completely fails to apply).The fix is quite simple: if a recipe update is deleting a file, instead of generating a "delete patch" for it, we run
git rm <filename>. The downside is that the user won't get a nice "file conflict" if they ever modified the file... but apparently that is not possible. And the user will still review this change before they commit.Bug 2️⃣ :
bundles.phpenvironments didn't changeIf an upgraded recipe changed the environments that a bundle is configured in (e.g. https://github.com/symfony/recipes/pull/940/files), this was previously not taken into account: the update did not update the environments. Fixed now.
Tested locally on a fairly complex project.
Thanks!