From 8735757c93678836d4e7f071079145f298a07e89 Mon Sep 17 00:00:00 2001 From: wyatt-avilla Date: Sun, 22 Oct 2023 12:56:31 -0700 Subject: [PATCH] changed to make only a single call to curl per link --- .github/workflows/testPatches.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/testPatches.sh b/.github/workflows/testPatches.sh index b3f8911..34973e4 100755 --- a/.github/workflows/testPatches.sh +++ b/.github/workflows/testPatches.sh @@ -22,15 +22,20 @@ for file in "$wikiDirectory"/*.md; do do if [[ $line =~ $patchRE ]]; then extractedURL=${BASH_REMATCH[0]} - patchAccessResult=$(curl -s -w "%{http_code}" -o /dev/null "$extractedURL") - if [ "$patchAccessResult" -ne 200 ]; then + response=$(curl -s -w "%{http_code}" -o - "$extractedURL") + + http_status_code="${response: -3}" + patchContent="${response:0:-3}" + + if [ "$http_status_code" -ne 200 ] || [ -z "$patchContent" ]; then echo "⚠️ - $extractedURL" update_line "$line" "inaccessible" continue fi - git -C "$dwlSrcDirectory" apply --check <(curl -s "$extractedURL") > /dev/null 2>&1 + git -C "$dwlSrcDirectory" apply --check <<< "$patchContent" > /dev/null 2>&1 patchApplicationExitCode=$? + if [ $patchApplicationExitCode -eq 0 ]; then echo "✅ - $extractedURL" update_line "$line" "pass" @@ -38,10 +43,7 @@ for file in "$wikiDirectory"/*.md; do echo "❌ - $extractedURL" update_line "$line" "fail" fi - fi done < "$file" - - fi done