Skip to content

Commit

Permalink
fix version_compare logic
Browse files Browse the repository at this point in the history
the -1 return from version_compare converts to 255 which was causing that to fail. this captures the output as a string that we can explicitly compare against.
  • Loading branch information
jazzsequence committed Oct 3, 2023
1 parent 7611368 commit 40f469e
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions bin/validate-fixture-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,22 @@ main(){
FIXTURE_VERSION=$(terminus wp "${TERMINUS_SITE}.dev" -- core version)
echo "Fixture Version: ${FIXTURE_VERSION}"

php -r "exit(version_compare('${TESTED_UP_TO}', '${FIXTURE_VERSION}'));"
exit_code=$?
compare_result=$(php -r "echo version_compare('${TESTED_UP_TO}', '${FIXTURE_VERSION}');")

if [ $exit_code -eq 255 ]; then
echo "An error occurred during version comparison."
if [ $compare_result == "-1" ]; then
echo "${FIXTURE_VERSION} is greater than ${TESTED_UP_TO}"
echo "You should update the 'Tested up to' in your plugin's readme.txt"
exit 1
elif [ $exit_code -eq 1 ]; then
elif [ $compare_result == "1" ]; then
echo "${FIXTURE_VERSION} is less than ${TESTED_UP_TO}"
echo "Please update ${TERMINUS_SITE} to at least WordPress ${TESTED_UP_TO}"
exit 1
elif [ $exit_code -eq 0 ]; then
elif [ $compare_result == "0" ]; then
echo "${FIXTURE_VERSION} is equal to ${TESTED_UP_TO}"
echo "No action required."
exit 0
else
echo "${FIXTURE_VERSION} is greater than ${TESTED_UP_TO}"
echo "You should update the 'Tested up to' in your plugin's readme.txt"
echo "An error occurred during version comparison."
exit 1
fi
}
Expand Down

0 comments on commit 40f469e

Please sign in to comment.