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
Use latest branch for test library, and always get the latest major release when 2 digit wp versions are used #35
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6da37ba
get latest update for major release
jdub233 97759f5
fix tag reference
jdub233 707d15f
add missing local declaration
jdub233 7a2202e
use latest_version instead of wp_version
jdub233 c95e1cb
Merge branch 'master' into install-latest-update
jdub233 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,8 +23,15 @@ download() { | |
fi | ||
} | ||
|
||
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then | ||
WP_TESTS_TAG="tags/$WP_VERSION" | ||
if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then | ||
WP_TESTS_TAG="branches/$WP_VERSION" | ||
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then | ||
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then | ||
# version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x | ||
WP_TESTS_TAG="tags/${WP_VERSION%??}" | ||
else | ||
WP_TESTS_TAG="tags/$WP_VERSION" | ||
fi | ||
elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then | ||
WP_TESTS_TAG="trunk" | ||
else | ||
|
@@ -57,6 +64,22 @@ install_wp() { | |
else | ||
if [ $WP_VERSION == 'latest' ]; then | ||
local ARCHIVE_NAME='latest' | ||
elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then | ||
# https serves multiple offers, whereas http serves single. | ||
download https://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json | ||
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then | ||
# version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x | ||
WP_VERSION=${WP_VERSION%??} | ||
else | ||
# otherwise, scan the releases and get the most up to date minor version of the major release | ||
local VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'` | ||
LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' /tmp/wp-latest.json | sed 's/"version":"//' | head -1) | ||
fi | ||
if [[ -z "$LATEST_VERSION" ]]; then | ||
local ARCHIVE_NAME="wordpress-$WP_VERSION" | ||
else | ||
ARCHIVE_NAME="wordpress-$LATEST_VERSION" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
fi | ||
else | ||
local ARCHIVE_NAME="wordpress-$WP_VERSION" | ||
fi | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should use a temporary local variable, to not change the global
$WP_VERSION
, which other code might depend on.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I was unsure of the best way to handle this. I had thought it might be okay to overwrite
$WP_VERSION
since the trailing zero (like4.7.0
) isn't actually a valid WP version. However,$WP_VERSION
is a direct user supplied argument so probably better not to alter it in the script.The most expedient solution would be to use
$LATEST_VERSION
. It's a little strange because it's not really the latest version, but maybe that's okay.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the variable here should be renamed, since
LATEST_VERSION
doesn't make so much sense when fetching the initial major release. Perhaps using a variable called something likeDOWNLOAD_VERSION
would be clearer?