refactor: improve script readability and maintainability in recalculate-patches.sh and remove-failed-jobs.sh

This commit is contained in:
mr. M 2025-03-30 10:05:54 +02:00
parent 3f2334a3ad
commit f8b6b05a25
No known key found for this signature in database
GPG key ID: CBD57A2AEDBDA1FB
2 changed files with 21 additions and 22 deletions

View file

@ -2,26 +2,25 @@
# Recursively find all .patch files in the current directory and its subdirectories # Recursively find all .patch files in the current directory and its subdirectories
find src -type f -name "*.patch" | while read -r patch_file; do find src -type f -name "*.patch" | while read -r patch_file; do
# Replace all - with . and remove the .patch extension # Replace all - with . and remove the .patch extension
new_file="${patch_file%/*}/$(basename "$patch_file" | sed 's/-/./' | sed 's/\.patch$//').patch" new_file="${patch_file%/*}/$(basename "$patch_file" | sed 's/-/./' | sed 's/\.patch$//').patch"
new_file="${new_file%.patch}" new_file="${new_file%.patch}"
new_file="${new_file#src/}" new_file="${new_file#src/}"
if [[ $new_file == *-mjs ]]; then if [[ $new_file == *-mjs ]]; then
new_file="${new_file/-mjs/.mjs}" new_file="${new_file/-mjs/.mjs}"
fi fi
if [[ $new_file == *-ftl ]]; then if [[ $new_file == *-ftl ]]; then
new_file="${new_file/-ftl/.ftl}" new_file="${new_file/-ftl/.ftl}"
fi fi
# Create the new file with the same content as the original # Create the new file with the same content as the original
npm run export ${new_file} & npm run export ${new_file} &
done done
for job in `jobs -p` for job in $(jobs -p); do
do echo $job
echo $job wait $job || let "FAIL+=1"
wait $job || let "FAIL+=1"
done done
echo "All patches have been exported successfully." echo "All patches have been exported successfully."

View file

@ -1,21 +1,21 @@
#!/bin/bash #!/bin/bash
gh_bulk_delete_workflow_runs() { gh_bulk_delete_workflow_runs() {
local repo=$1 local repo=zen-browser/$1
# Ensure the repo argument is provided # Ensure the repo argument is provided
if [[ -z "$repo" ]]; then if [[ -z "$repo" ]]; then
echo "Usage: gh_bulk_delete_workflow_runs <owner/repo>" echo "Usage: gh_bulk_delete_workflow_runs <repo>"
return 1 return 1
fi fi
# Fetch workflow runs that are cancelled, failed, or timed out # Fetch workflow runs that are cancelled, failed, or timed out
local runs local runs
runs=$(gh api repos/$repo/actions/runs --paginate \ runs=$(gh api repos/$repo/actions/runs --paginate \
| jq -r '.workflow_runs[] | | jq -r '.workflow_runs[] |
select(.conclusion == "cancelled" or select(.conclusion == "cancelled" or
.conclusion == "failure" or .conclusion == "failure" or
.conclusion == "timed_out") | .conclusion == "timed_out") |
.id') .id')
if [[ -z "$runs" ]]; then if [[ -z "$runs" ]]; then