From 6da37bab9759d3170d951246ce16fc1ec885f907 Mon Sep 17 00:00:00 2001 From: jdub233 Date: Mon, 7 Aug 2017 17:11:54 -0400 Subject: [PATCH 1/4] get latest update for major release --- templates/install-wp-tests.sh | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/templates/install-wp-tests.sh b/templates/install-wp-tests.sh index 73bb4c787..2e9da6b92 100644 --- a/templates/install-wp-tests.sh +++ b/templates/install-wp-tests.sh @@ -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="branches/${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" + fi else local ARCHIVE_NAME="wordpress-$WP_VERSION" fi From 97759f54d50a25b9fd79b479a7c5f64847dc8320 Mon Sep 17 00:00:00 2001 From: jdub233 Date: Mon, 7 Aug 2017 17:21:18 -0400 Subject: [PATCH 2/4] fix tag reference --- templates/install-wp-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/install-wp-tests.sh b/templates/install-wp-tests.sh index 2e9da6b92..865443949 100644 --- a/templates/install-wp-tests.sh +++ b/templates/install-wp-tests.sh @@ -28,7 +28,7 @@ if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then 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="branches/${WP_VERSION%??}" + WP_TESTS_TAG="tags/${WP_VERSION%??}" else WP_TESTS_TAG="tags/$WP_VERSION" fi From 707d15fe2751caf3ccb99147d34778c4b4d3e3b3 Mon Sep 17 00:00:00 2001 From: jdub233 Date: Tue, 8 Aug 2017 10:37:04 -0400 Subject: [PATCH 3/4] add missing local declaration --- templates/install-wp-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/install-wp-tests.sh b/templates/install-wp-tests.sh index 865443949..df296c98b 100644 --- a/templates/install-wp-tests.sh +++ b/templates/install-wp-tests.sh @@ -78,7 +78,7 @@ install_wp() { if [[ -z "$LATEST_VERSION" ]]; then local ARCHIVE_NAME="wordpress-$WP_VERSION" else - ARCHIVE_NAME="wordpress-$LATEST_VERSION" + local ARCHIVE_NAME="wordpress-$LATEST_VERSION" fi else local ARCHIVE_NAME="wordpress-$WP_VERSION" From 7a2202e9354edb3bc3c4f12e8752ca3140ab3ba3 Mon Sep 17 00:00:00 2001 From: jdub233 Date: Tue, 8 Aug 2017 11:32:09 -0400 Subject: [PATCH 4/4] use latest_version instead of wp_version --- templates/install-wp-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/install-wp-tests.sh b/templates/install-wp-tests.sh index df296c98b..87180fce1 100644 --- a/templates/install-wp-tests.sh +++ b/templates/install-wp-tests.sh @@ -69,7 +69,7 @@ install_wp() { 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%??} + LATEST_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'`