#!/usr/bin/env bash set -euo pipefail # ============================================================================= # phase7_teardown.sh — Remove branch protection rules from all repos # Deletes the PROTECTED_BRANCH protection rule via API. # Safe to run if protection rules have already been removed. # ============================================================================= SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" source "${SCRIPT_DIR}/lib/common.sh" # Parse arguments AUTO_YES=false for arg in "$@"; do case "$arg" in --yes|-y) AUTO_YES=true ;; --help|-h) cat </dev/null 2>&1; then gitea_api DELETE "/repos/${GITEA_ORG_NAME}/${repo}/branch_protections/${PROTECTED_BRANCH}" >/dev/null 2>&1 || true log_success "Removed branch protection from ${repo}" else log_info "No branch protection on ${repo} — already clean" fi done log_success "Phase 7 teardown complete"