fix(dev-env): count deleted backups in the parent shell, not a subshell
cleanup_backups piped `git branch --list` into `while read`, so the `deleted` counter incremented inside a pipeline subshell and never propagated. The closing "Deleted N backup branch(es)" always reported 0, however many were actually removed. Switch the inner loop to process substitution (matching the outer find_forked_repos loop) so the count survives.
This commit is contained in:
parent
11cf5aa0cf
commit
cd95974e48
1 changed files with 2 additions and 2 deletions
|
|
@ -311,7 +311,7 @@ cleanup_backups() {
|
|||
local deleted=0
|
||||
while IFS=: read -r path _; do
|
||||
cd "$path" || continue
|
||||
git branch --list "backup/*" 2>/dev/null | while read -r branch; do
|
||||
while read -r branch; do
|
||||
branch="$(echo "$branch" | tr -d ' *')"
|
||||
local bdate
|
||||
bdate="$(echo "$branch" | grep -oE '[0-9]{8}' | head -1)"
|
||||
|
|
@ -319,7 +319,7 @@ cleanup_backups() {
|
|||
|| { [[ -n "$bdate" ]] && [[ "$bdate" < "$cutoff" ]]; }; then
|
||||
git branch -D "$branch" 2>/dev/null && deleted=$((deleted + 1)) || true
|
||||
fi
|
||||
done
|
||||
done < <(git branch --list "backup/*" 2>/dev/null)
|
||||
done < <(find_forked_repos)
|
||||
success "Deleted $deleted backup branch(es)."
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue