changed to make only a single call to curl per link

This commit is contained in:
wyatt-avilla 2023-10-22 12:56:31 -07:00
parent 5f1592fa7a
commit 8735757c93

View File

@ -22,15 +22,20 @@ for file in "$wikiDirectory"/*.md; do
do do
if [[ $line =~ $patchRE ]]; then if [[ $line =~ $patchRE ]]; then
extractedURL=${BASH_REMATCH[0]} extractedURL=${BASH_REMATCH[0]}
patchAccessResult=$(curl -s -w "%{http_code}" -o /dev/null "$extractedURL") response=$(curl -s -w "%{http_code}" -o - "$extractedURL")
if [ "$patchAccessResult" -ne 200 ]; then
http_status_code="${response: -3}"
patchContent="${response:0:-3}"
if [ "$http_status_code" -ne 200 ] || [ -z "$patchContent" ]; then
echo "⚠️ - $extractedURL" echo "⚠️ - $extractedURL"
update_line "$line" "inaccessible" update_line "$line" "inaccessible"
continue continue
fi fi
git -C "$dwlSrcDirectory" apply --check <(curl -s "$extractedURL") > /dev/null 2>&1 git -C "$dwlSrcDirectory" apply --check <<< "$patchContent" > /dev/null 2>&1
patchApplicationExitCode=$? patchApplicationExitCode=$?
if [ $patchApplicationExitCode -eq 0 ]; then if [ $patchApplicationExitCode -eq 0 ]; then
echo "✅ - $extractedURL" echo "✅ - $extractedURL"
update_line "$line" "pass" update_line "$line" "pass"
@ -38,10 +43,7 @@ for file in "$wikiDirectory"/*.md; do
echo "❌ - $extractedURL" echo "❌ - $extractedURL"
update_line "$line" "fail" update_line "$line" "fail"
fi fi
fi fi
done < "$file" done < "$file"
fi fi
done done