Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[recipes:update] Fixing bug where files failed to delete that were modified previously #895

Merged
merged 1 commit into from
Apr 15, 2022

Conversation

weaverryan
Copy link
Member

@weaverryan weaverryan commented Apr 9, 2022

Hi!

This fixes TWO recipes:update bugs:

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.yaml is deleted in symfony/framework-bundle recipe, this patch is correctly generated

diff --git a/config/routes/dev/framework.yaml b/config/routes/dev/framework.yaml
deleted file mode 100644
index bcbbf13..0000000
--- a/config/routes/dev/framework.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-_errors:
-    resource: '@FrameworkBundle/Resources/config/routing/errors.xml'
-    prefix: /_error

However, if the user's framework.yaml doesn'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.php environments didn't change

If 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!

unlink($filename);
}
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method just refactored from above, with no changes

@weaverryan weaverryan force-pushed the fix-update-deleted-files branch 3 times, most recently from 6fb1f9c to 7d6a16d Compare April 10, 2022 01:14
@fabpot
Copy link
Member

fabpot commented Apr 15, 2022

Thank you @weaverryan.

@fabpot fabpot merged commit 2c857c0 into symfony:1.x Apr 15, 2022
@weaverryan weaverryan deleted the fix-update-deleted-files branch April 20, 2022 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants