Commit 01d55d55 authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Debug

parent fc99fedd
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ urlencode() {

# ==== Initialize ====
page=1
deleted_branches=0
cd logs

echo "Dry-run mode: $DRY_RUN"
@@ -56,16 +57,16 @@ while true; do
    fi

    if [[ "$last_commit_date" < "$ONE_YEAR_AGO" ]]; then
      echo "==> OLD branch: $branch_name (last commit: $last_commit_date)"
      ((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)"
        echo "[DRY-RUN] Would delete: $branch_name (last commit: $last_commit_date)" >> "$LOG_FILE"
      else
        encoded_branch=$(urlencode "$branch_name")
        delete_response=$(curl --silent --request DELETE \
          --header "PRIVATE-TOKEN: $PRIVATE_TOKEN" \
          "$1/projects/$PROJECT_ID/repository/branches/$encoded_branch")

        echo "$branch_name - $last_commit_date" >> "$LOG_FILE"
        echo "Deleted: $branch_name"
      fi
    else
@@ -76,5 +77,7 @@ while true; do
  ((page++))
done

echo "Total deleted branches: $deleted_branches" >> "$LOG_FILE"

echo "Done. Deleted branches logged to: $LOG_FILE"