From ee5e69a5064aca4981bd22c501b3190d072b1889 Mon Sep 17 00:00:00 2001 From: jdub233 Date: Fri, 4 Aug 2017 10:35:53 -0400 Subject: [PATCH 1/8] parse for minor release number --- bin/install-wp-tests.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh index 2122302..8ca83c3 100755 --- a/bin/install-wp-tests.sh +++ b/bin/install-wp-tests.sh @@ -59,6 +59,17 @@ 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 + grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json + VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'` + LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' /tmp/wp-latest.json | sed 's/"version":"//' | head -1) + 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 6527d0f011eb0c61c6bb199407e767a92132527b Mon Sep 17 00:00:00 2001 From: jdub233 Date: Fri, 4 Aug 2017 11:13:06 -0400 Subject: [PATCH 2/8] remove unhelpful grep --- bin/install-wp-tests.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh index 8ca83c3..5834009 100755 --- a/bin/install-wp-tests.sh +++ b/bin/install-wp-tests.sh @@ -62,7 +62,6 @@ install_wp() { 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 - grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'` LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' /tmp/wp-latest.json | sed 's/"version":"//' | head -1) if [[ -z "$LATEST_VERSION" ]]; then From 12289cfba677a00e07aed63fa097452a58759e18 Mon Sep 17 00:00:00 2001 From: jdub233 Date: Mon, 7 Aug 2017 11:22:58 -0400 Subject: [PATCH 3/8] check minor version Correctly handle x.x.0 input as the original major release --- bin/install-wp-tests.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh index 5834009..38c8884 100755 --- a/bin/install-wp-tests.sh +++ b/bin/install-wp-tests.sh @@ -62,11 +62,17 @@ install_wp() { 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 - VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'` - LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' /tmp/wp-latest.json | sed 's/"version":"//' | head -1) + 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 + else ARCHIVE_NAME="wordpress-$LATEST_VERSION" fi else From 92450cf19e0e2ada22b45cd1b7d82ba2f0b60aba Mon Sep 17 00:00:00 2001 From: jdub233 Date: Mon, 7 Aug 2017 12:24:13 -0400 Subject: [PATCH 4/8] fix regex for tests download --- bin/install-wp-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh index 38c8884..cbfaefa 100755 --- a/bin/install-wp-tests.sh +++ b/bin/install-wp-tests.sh @@ -23,7 +23,7 @@ download() { fi } -if [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then +if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then WP_TESTS_TAG="branches/$WP_VERSION" elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then WP_TESTS_TAG="tags/$WP_VERSION" From 14c6565e99b65f355d9d7c17f1ede1fc40e5b7a5 Mon Sep 17 00:00:00 2001 From: jdub233 Date: Mon, 7 Aug 2017 13:50:24 -0400 Subject: [PATCH 5/8] handle point zero case for tests --- bin/install-wp-tests.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh index cbfaefa..04e8c28 100755 --- a/bin/install-wp-tests.sh +++ b/bin/install-wp-tests.sh @@ -26,7 +26,12 @@ download() { if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then WP_TESTS_TAG="branches/$WP_VERSION" elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then - WP_TESTS_TAG="tags/$WP_VERSION" + 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 From 9e113d76ad0bc138b9319b7be47b3652ae97cd59 Mon Sep 17 00:00:00 2001 From: jdub233 Date: Mon, 7 Aug 2017 16:56:37 -0400 Subject: [PATCH 6/8] fix spacing --- bin/install-wp-tests.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh index 04e8c28..747f4e3 100755 --- a/bin/install-wp-tests.sh +++ b/bin/install-wp-tests.sh @@ -65,8 +65,8 @@ install_wp() { 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 + # 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%??} @@ -76,10 +76,10 @@ install_wp() { 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" + local ARCHIVE_NAME="wordpress-$WP_VERSION" else - ARCHIVE_NAME="wordpress-$LATEST_VERSION" - fi + ARCHIVE_NAME="wordpress-$LATEST_VERSION" + fi else local ARCHIVE_NAME="wordpress-$WP_VERSION" fi From 2261408d4f417f6eb41a70fd797884ce8e11fc6c Mon Sep 17 00:00:00 2001 From: jdub233 Date: Tue, 8 Aug 2017 10:51:44 -0400 Subject: [PATCH 7/8] add missing local declaration --- bin/install-wp-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh index 747f4e3..f24093b 100755 --- a/bin/install-wp-tests.sh +++ b/bin/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 aa375aca801710ba9417c8ff37de4b72970ac75b Mon Sep 17 00:00:00 2001 From: jdub233 Date: Tue, 8 Aug 2017 11:08:31 -0400 Subject: [PATCH 8/8] use latest_version instead of wp_version --- bin/install-wp-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/install-wp-tests.sh b/bin/install-wp-tests.sh index f24093b..9f17a24 100755 --- a/bin/install-wp-tests.sh +++ b/bin/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'`