Skip to content

Commit

Permalink
Merge pull request #110 from AmpersandHQ/poc-meaningful-semantic-unde…
Browse files Browse the repository at this point in the history
…rstanding-of-file-changes

Report redundant overrides, and ignore non-meaningful changes in `vendor`
  • Loading branch information
convenient authored Nov 9, 2023
2 parents c9af2ca + 4075afe commit e94978d
Show file tree
Hide file tree
Showing 93 changed files with 1,869 additions and 119 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ Helper scripts to aid upgrading magento 2 websites, or when upgrading a magento

[![Build Status](https://travis-ci.org/AmpersandHQ/ampersand-magento2-upgrade-patch-helper.svg?branch=master)](https://app.travis-ci.com/github/AmpersandHQ/ampersand-magento2-upgrade-patch-helper)

This tool looks for files which have been modified as part of the upgrade and attempts to see if you have any overrides in your site. This allows you to focus in on only the things that have changed and are specific to your site.
This tool looks for files which have been modified as part of an upgrade and highlights any overrides for those specific files in your magento instance. This allows you to focus in on only the things that have changed, and gives you an actionable list of things to review specifically for your site.

This tool does a number of checks split into two categories
This tool does a number of checks split into three categories
- `WARN` - Warning level items are something that you should review and often require direct code changes. Something you or a third party have customised may need adjustment or no longer be valid based on the upgraded codebase.
- `INFO` - Information level items are something that you may want to know, but there is not always direct action necessary. These items are hidden by default and exposed with `--show-info`.
- `IGNR` - Ignore level items are something that you can ignore. The vendor file change which triggered the analysis was actually a comment/whitespace or other non functional change so there is nothing to check. These items are hidden by default and exposed with `--show-ignore`.

This tool checks for the following
- Preferences (in global/frontend/adminhtml di.xml)
Expand Down Expand Up @@ -102,6 +103,7 @@ For those of you who would prefer to work over these results in a GUI rather tha
| WARN | Preference | vendor/magento/module-advanced-pricing-import-export/Model/Export/AdvancedPricing.php | Ampersand\Test\Model\Admin\Export\AdvancedPricing |
| WARN | Preference | vendor/magento/module-weee/Model/Total/Quote/Weee.php | Ampersand\Test\Model\Frontend\Total\Quote\Weee |
| WARN | Preference | vendor/magento/module-weee/Model/Total/Quote/Weee.php | Ampersand\Test\Model\Total\Quote\Weee |
| WARN | Redundant Override | vendor/ampersand/some-nice-theme/Magento_Ui/web/templates/redundant.html | app/design/frontend/Ampersand/theme/Magento_Ui/web/templates/redundant.html |
+-------+--------------------------+----------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------+
WARN count: 18
INFO count: 381 (to view re-run this tool with --show-info)
Expand All @@ -118,6 +120,14 @@ php bin/patch-helper.php analyse /path/to/magento2/ --show-info

Show all `INFO` level items, this can be a lot more output and give you a broader view of the system changes.

### --show-ignore

```
php bin/patch-helper.php analyse /path/to/magento2/ --show-ignore
```

Show all `IGNR` level items, see https://github.com/AmpersandHQ/ampersand-magento2-upgrade-patch-helper/blob/master/docs/CHECKS_AVAILABLE.md#ignr---ignored-warnings

### --auto-theme-update

```
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
],
"require": {
"symfony/console": "^3.4|^4.0",
"php": "~7.2|~7.3|~7.4|~8.1|~8.2"
"php": "~7.2|~7.3|~7.4|~8.1|~8.2",
"ext-libxml": "*"
},
"autoload": {
"classmap": ["src/"],
Expand Down
5 changes: 3 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 34 additions & 11 deletions dev/Docker/setup-magento-with-diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,28 +96,51 @@ else
$COMPOSER_TO install --no-interaction --ignore-platform-reqs
fi
# Spoof some changes into our "third party" test module so they appear in the diff
echo "<!-- -->" >> vendor/ampersand/upgrade-patch-helper-test-hyva-fallback-theme/theme/Magento_Customer/templates/account/dashboard/info.phtml
echo "<!-- -->" >> vendor/ampersand/upgrade-patch-helper-test-hyva-theme-stub/theme/Magento_Checkout/templates/cart/form.phtml
echo "<!-- -->" >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/view/frontend/templates/checkout/something.phtml
echo "<!-- -->" >> vendor/ampersand/upgrade-patch-helper-test-module/src/theme/Magento_Checkout/templates/cart/form.phtml # ensure that third party theme modifications show as expected
echo "<span/>" >> vendor/ampersand/upgrade-patch-helper-test-hyva-fallback-theme/theme/Magento_Customer/templates/account/dashboard/info.phtml
echo "<span/>" >> vendor/ampersand/upgrade-patch-helper-test-hyva-theme-stub/theme/Magento_Checkout/templates/cart/form.phtml
echo "<span/>" >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/view/frontend/templates/checkout/something.phtml
echo "<span/>" >> vendor/ampersand/upgrade-patch-helper-test-module/src/theme/Magento_Checkout/templates/cart/form.phtml # ensure that third party theme modifications show as expected
rm vendor/ampersand/upgrade-patch-helper-test-module/src/module/Model/ToPreferenceAndDelete.php
rm vendor/ampersand/upgrade-patch-helper-test-module/src/module/Model/ToPreferenceAndExtendAndDelete.php
echo "//some change" >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Model/SomeClass.php
echo "//some change" >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Api/ExampleInterface.php
echo "//some change" >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Api/ExampleTwoInterface.php
echo "//some change" >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Setup/Patch/Schema/SomeSchemaChanges.php
echo "//some change" >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Setup/Patch/Data/SomeDataChanges.php
echo "//some change" >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Setup/InstallSchema.php
echo '//not-meaningful' >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Model/ToPreferenceAndIgnore.php
echo '//not-meaningful' >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Model/ToPluginAndIgnore.php
echo '$b=1;' >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Model/SomeClass.php
echo '$b=1;' >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Api/ExampleInterface.php
echo '$b=1;' >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Api/ExampleTwoInterface.php
echo '$b=1;' >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Setup/Patch/Schema/SomeSchemaChanges.php
echo '$b=1;' >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Setup/Patch/Data/SomeDataChanges.php
echo '//not-meaningful' >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Setup/Patch/Schema/SomeSchemaNonChanges.php
echo '//not-meaningful' >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Setup/Patch/Data/SomeDataNonChanges.php
echo '$b=1;' >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/Setup/InstallSchema.php
cp vendor/ampersand/upgrade-patch-helper-test-module/src/module/etc/db_schema.after.xml vendor/ampersand/upgrade-patch-helper-test-module/src/module/etc/db_schema.xml
rm vendor/ampersand/upgrade-patch-helper-test-module-to-be-removed/src/module/etc/db_schema.xml

if [[ "$MAGE_TO" == 2.3* ]]; then
echo "<span/>" >> vendor/magento/module-bundle/view/frontend/templates/js/components.phtml
fi

# Ensure all test cases that were in the 2.2 series tests are represented in others
echo "//some change" >> vendor/magento/module-sales/Block/Adminhtml/Order/Create/Form.php
echo "<!-- -->" >> vendor/magento/module-ui/view/base/web/templates/block-loader.html
echo "<!-- --><p>some change</p>" >> vendor/magento/module-ui/view/base/web/templates/block-loader.html

# Redundant override
echo " " >> vendor/ampersand/upgrade-patch-helper-test-module/src/theme/Magento_Ui/web/templates/redundant.html
echo " " >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/view/frontend/email/redundant.html
echo " " >> vendor/ampersand/upgrade-patch-helper-test-module/src/theme/Magento_Checkout/web/js/redundant.js
echo " " >> vendor/ampersand/upgrade-patch-helper-test-hyva-theme-stub/theme/Magento_Checkout/templates/cart/redundant.phtml

# Ignored change
echo "<!-- -->" >> vendor/ampersand/upgrade-patch-helper-test-module/src/theme/Magento_Ui/web/templates/ignore.html
echo "<!-- -->" >> vendor/ampersand/upgrade-patch-helper-test-module/src/module/view/frontend/email/ignore.html
echo "/* some comment */" >> vendor/ampersand/upgrade-patch-helper-test-module/src/theme/Magento_Checkout/web/js/ignore.js
echo "<!-- -->" >> vendor/ampersand/upgrade-patch-helper-test-hyva-theme-stub/theme/Magento_Checkout/templates/cart/ignored.phtml

echo "#" >> vendor/magento/module-customer/view/frontend/web/js/model/authentication-popup.js

# Ensure change in catalog default.xml layout
echo "<!-- -->" >> vendor/magento/module-catalog/view/frontend/layout/default.xml
echo "<!-- -->" >> vendor/magento/module-catalog/view/frontend/layout/catalog_category_view_type_default.xml
echo "<!-- -->" >> vendor/magento/module-rss/view/frontend/layout/default.xml

# Install test module and theme
echo "Installing test module"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>ignored - some customisation</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>redundant</p>
Loading

0 comments on commit e94978d

Please sign in to comment.