1
0
Fork 1
mirror of https://github.com/zen-browser/desktop.git synced 2025-07-07 21:49:58 +02:00

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

View file

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