mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-10-27 10:14:14 +00:00
replacement functionality works
This commit is contained in:
parent
8735757c93
commit
4c84f36aaa
78
.github/workflows/testPatches.sh
vendored
78
.github/workflows/testPatches.sh
vendored
@ -1,49 +1,59 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
update_line() {
|
# wiki directory was initially formatted via: sed -i '/https:\/\/github\.com\/[^/]\+\/[^/]\+\/compare\/[^/]\+\.patch/s/$/ [❔]/'
|
||||||
local line="$1" # line from opened file is passed in
|
|
||||||
local testResult="$2" # result from git diff
|
|
||||||
|
|
||||||
echo "Processing line: $line with additional argument: $testResult"
|
|
||||||
}
|
|
||||||
|
|
||||||
dwlSrcDirectory="$1"
|
dwlSrcDirectory="$1"
|
||||||
wikiDirectory="$2"
|
wikiDirectory="$2"
|
||||||
patchRE="https://github\.com/[^/]+/[^/]+/compare/[^/]+\.patch"
|
patchLinkPattern="https://github\.com/[^/]+/[^/]+/compare/[^/]+\.patch"
|
||||||
|
emojiReplacePattern="\(\[[❔⚠️❌✅]\]\)"
|
||||||
|
|
||||||
for file in "$wikiDirectory"/*.md; do
|
for file in "$wikiDirectory"/*.md; do
|
||||||
if [ -f "$file" ]; then
|
|
||||||
if ! grep -q "Download" "$file"; then
|
bFileName=$(basename "$file")
|
||||||
echo "no download heading found in $file, skipping..."
|
if ! [ -f "$file" ] ||
|
||||||
|
[ "$bFileName" == "Patches.md" ] || \
|
||||||
|
[ "$bFileName" == "Screenshots.md" ] || \
|
||||||
|
[ "$bFileName" == "Home.md" ] || \
|
||||||
|
[ "$bFileName" == "_Sidebar.md" ]; then
|
||||||
|
echo "$file is invalid, skipping"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if ! grep -q "Download" "$file"; then
|
||||||
|
echo "no download heading found in $file, skipping..."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
tempFile="$file.tmp"
|
||||||
|
touch "$tempFile"
|
||||||
|
while IFS= read -r line || [ -n "$line" ]; do
|
||||||
|
if ! [[ $line =~ $patchLinkPattern ]]; then # not a download link
|
||||||
|
echo "$line" >> "$tempFile"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while IFS= read -r line
|
extractedURL=${BASH_REMATCH[0]}
|
||||||
do
|
response=$(curl -s -w "%{http_code}" -o - "$extractedURL")
|
||||||
if [[ $line =~ $patchRE ]]; then
|
|
||||||
extractedURL=${BASH_REMATCH[0]}
|
|
||||||
response=$(curl -s -w "%{http_code}" -o - "$extractedURL")
|
|
||||||
|
|
||||||
http_status_code="${response: -3}"
|
http_status_code="${response: -3}"
|
||||||
patchContent="${response:0:-3}"
|
patchContent="${response:0:-3}"
|
||||||
|
|
||||||
if [ "$http_status_code" -ne 200 ] || [ -z "$patchContent" ]; then
|
if [ "$http_status_code" -ne 200 ] || [ -z "$patchContent" ]; then
|
||||||
echo "⚠️ - $extractedURL"
|
echo "[⚠️] -- $extractedURL"
|
||||||
update_line "$line" "inaccessible"
|
echo "$line" | sed "s/$emojiReplacePattern/[⚠️]/1" >> "$tempFile"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git -C "$dwlSrcDirectory" apply --check <<< "$patchContent" > /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"
|
echo "$line" | sed "s/$emojiReplacePattern/[✅]/1" >> "$tempFile"
|
||||||
else
|
else
|
||||||
echo "❌ - $extractedURL"
|
echo "[❌] -- $extractedURL"
|
||||||
update_line "$line" "fail"
|
echo "$line" | sed "s/$emojiReplacePattern/[❌]/1" >> "$tempFile"
|
||||||
fi
|
fi
|
||||||
fi
|
done < "$file"
|
||||||
done < "$file"
|
|
||||||
fi
|
mv "$tempFile" "$file"
|
||||||
done
|
done
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user