Initial commit

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
timmy
2026-04-21 13:04:09 +08:00
commit faee15bc78
18 changed files with 3278 additions and 0 deletions

48
scripts/delete.sh Normal file
View File

@@ -0,0 +1,48 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=lib/common.sh
source "${SCRIPT_DIR}/lib/common.sh"
usage() {
cat >&2 <<'EOF'
Usage: delete.sh <repo> [-y|--yes]
互動模式:會要求重新輸入完整 repo 名稱才執行。
-y / --yes 或 GITEA_YES=1直接執行不需輸入。
EOF
exit 1
}
[[ $# -ge 1 ]] || usage
REPO=""
while [[ $# -gt 0 ]]; do
case "$1" in
-y|--yes) GITEA_YES=1; shift ;;
-h|--help) usage ;;
-*) log_err "未知參數:$1"; usage ;;
*)
if [[ -z "$REPO" ]]; then REPO="$1"; else log_err "多餘參數:$1"; usage; fi
shift ;;
esac
done
[[ -n "$REPO" ]] || usage
load_config
log_warn "即將刪除 ${GITEA_USER}/${REPO}(此操作不可復原)"
confirm_exact_match "$REPO"
log_info "刪除 ${GITEA_USER}/${REPO}"
gitea_api DELETE "/repos/${GITEA_USER}/${REPO}"
case "$HTTP_CODE" in
204) log_ok "已刪除" ;;
404) log_err "找不到 repo${GITEA_USER}/${REPO}"; exit 1 ;;
*) log_err "刪除失敗 (HTTP ${HTTP_CODE})"; { cat "$GITEA_API_RESP_FILE"; echo ""; } >&2; exit 1 ;;
esac
log_done "完成"