Loading sa5/delete_old_branches.sh +6 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ echo "CI_PROJECT_ID:" $2 PRIVATE_TOKEN=$3 ONE_YEAR_AGO=$(date -d '1 year ago' --iso-8601=seconds) DRY_RUN=true # Set to false to actually delete MY_VARIABLE=true LOG_FILE="deleted_branches_$(date +%Y%m%d_%H%M%S).log" # ==== Helper: URL encode ==== Loading @@ -35,6 +36,7 @@ cd logs echo "Dry-run mode: $DRY_RUN" echo "Log file: $LOG_FILE" echo "" > "$LOG_FILE" # Start fresh echo "My variable: $MY_VARIABLE" # ==== Loop over paginated branch list ==== while true; do Loading @@ -46,7 +48,8 @@ while true; do break fi echo "$response" | jq -c '.[]' | while read -r branch; do jq -c '.[]' <<< "$response" > /tmp/branches.json while read -r branch; do branch_name=$(printf '%s' "$branch" | jq -r '.name') is_protected=$(printf '%s' "$branch" | jq -r '.protected') last_commit_date=$(printf '%s' "$branch" | jq -r '.commit.committed_date') Loading @@ -57,7 +60,7 @@ while true; do fi if [[ "$last_commit_date" < "$ONE_YEAR_AGO" ]]; then deleted_branches=$((deleted_branches++)) ((deleted_branches++)) echo "==> OLD branch: $branch_name (last commit: $last_commit_date)" >> "$LOG_FILE" if [ "$DRY_RUN" = true ]; then echo "[DRY-RUN] Would delete: $branch_name (last commit: $last_commit_date)" >> "$LOG_FILE" Loading @@ -72,7 +75,7 @@ while true; do else echo "Keeping branch: $branch_name (last commit: $last_commit_date)" fi done done < /tmp/branches.json ((page++)) done Loading Loading
sa5/delete_old_branches.sh +6 −3 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ echo "CI_PROJECT_ID:" $2 PRIVATE_TOKEN=$3 ONE_YEAR_AGO=$(date -d '1 year ago' --iso-8601=seconds) DRY_RUN=true # Set to false to actually delete MY_VARIABLE=true LOG_FILE="deleted_branches_$(date +%Y%m%d_%H%M%S).log" # ==== Helper: URL encode ==== Loading @@ -35,6 +36,7 @@ cd logs echo "Dry-run mode: $DRY_RUN" echo "Log file: $LOG_FILE" echo "" > "$LOG_FILE" # Start fresh echo "My variable: $MY_VARIABLE" # ==== Loop over paginated branch list ==== while true; do Loading @@ -46,7 +48,8 @@ while true; do break fi echo "$response" | jq -c '.[]' | while read -r branch; do jq -c '.[]' <<< "$response" > /tmp/branches.json while read -r branch; do branch_name=$(printf '%s' "$branch" | jq -r '.name') is_protected=$(printf '%s' "$branch" | jq -r '.protected') last_commit_date=$(printf '%s' "$branch" | jq -r '.commit.committed_date') Loading @@ -57,7 +60,7 @@ while true; do fi if [[ "$last_commit_date" < "$ONE_YEAR_AGO" ]]; then deleted_branches=$((deleted_branches++)) ((deleted_branches++)) echo "==> OLD branch: $branch_name (last commit: $last_commit_date)" >> "$LOG_FILE" if [ "$DRY_RUN" = true ]; then echo "[DRY-RUN] Would delete: $branch_name (last commit: $last_commit_date)" >> "$LOG_FILE" Loading @@ -72,7 +75,7 @@ while true; do else echo "Keeping branch: $branch_name (last commit: $last_commit_date)" fi done done < /tmp/branches.json ((page++)) done Loading