-
-
Save costdev/aa378e1e04c84b6f36752cbf548b320f to your computer and use it in GitHub Desktop.
Convert non-Yoda to Yoda for backport.
This file contains 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
#!/bin/bash | |
COMMIT=$1 | |
BRANCH=$2 | |
# Checkout the commit. | |
git checkout "$COMMIT" | |
# Undo the commit. | |
git reset --soft HEAD^ | |
git restore --staged . | |
# Install the Slevomat coding standard. | |
yes | composer require "slevomat/coding-standard" "~7.0" --dev | |
# Apply the relevant autofix sniff. | |
vendor/bin/phpcbf $(git diff --name-only) --standard=SlevomatCodingStandard --sniffs=SlevomatCodingStandard.ControlStructures.RequireYodaComparison | |
# Remove the Slevomat coding standard. | |
yes | composer remove "slevomat/coding-standard" --dev | |
# Stash the changes. | |
git stash | |
# Switch to the commit branch. | |
git checkout "$BRANCH" | |
# Apply the stashed changes. | |
git stash pop | |
# The commit is now ready for final review before backporting. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment