Skip to content

Commit 8f9d62d

Browse files
authored
Remove subshell and else from php version check (#1)
1 parent 5c0b976 commit 8f9d62d

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

bin/validate-plugin-version.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ main(){
3636
echo "Tested up to version not found in readme.txt."
3737
exit 1
3838
fi
39-
40-
# Compare versions using PHP
41-
COMPARE_VERSIONS=$(php -r "echo version_compare('$TESTED_UP_TO', '$CURRENT_WP_VERSION');")
42-
echo "Comparison result: $COMPARE_VERSIONS"
4339

44-
if [[ $COMPARE_VERSIONS -eq -1 ]]; then
40+
# Compare versions using PHP
41+
if php -r "exit(version_compare('$TESTED_UP_TO', '$CURRENT_WP_VERSION', '>=') ? 0 : 1);"; then
42+
echo "Tested up to version matches or is greater than the current WordPress version. Check passed."
43+
exit
44+
fi
4545
echo "Tested up to version ($TESTED_UP_TO) is less than current WordPress version ($CURRENT_WP_VERSION)."
4646
echo "Updating readme.txt with new Tested up to version."
4747

@@ -84,9 +84,6 @@ main(){
8484
git push origin "$BRANCH_NAME"
8585

8686
gh pr create --title "Update Tested Up To version to $CURRENT_WP_VERSION" --body "This pull request updates the \"Tested up to\" version in readme.txt (and README.md if applicable) to match the current WordPress version $CURRENT_WP_VERSION."
87-
else
88-
echo "Tested up to version matches or is greater than the current WordPress version. Check passed."
89-
fi
9087
}
9188

9289
main

0 commit comments

Comments
 (0)