diff --git a/.gitea/workflows/mirror.yml b/.gitea/workflows/mirror.yml index 78dd220..8441845 100644 --- a/.gitea/workflows/mirror.yml +++ b/.gitea/workflows/mirror.yml @@ -44,6 +44,7 @@ jobs: ROOT_DIR="$(pwd)" NOTIFY_WEBHOOK="${NOTIFY_WEBHOOK:-}" SYNC_TAGS="${SYNC_TAGS:-true}" + TARGET_SEED_DEPTH="${TARGET_SEED_DEPTH:-50}" TOTAL_SUCCESS=0 TOTAL_SKIP=0 TOTAL_ERROR=0 @@ -258,11 +259,23 @@ jobs: echo "Fetching latest branch '${branch_name}' from source..." if ! git fetch --no-tags "${shallow_exclude_args[@]}" source "+refs/heads/${branch_name}:refs/heads/${branch_name}"; then - echo "::error::Failed to fetch branch '${branch_name}' from source repo" - notify_status "error" "${repo_name}" "${branch_name}" "${backup_mode}" "${start_epoch}" "source fetch 오류" - cd "${ROOT_DIR}" - rm -rf "${CLONE_DIR}" - return + if [[ "${#shallow_exclude_args[@]}" -gt 0 ]]; then + echo "::warning::shallow-exclude not supported; retrying with target main seed(depth=${TARGET_SEED_DEPTH}) and full fetch" + git fetch --no-tags --depth="${TARGET_SEED_DEPTH}" origin "refs/heads/main:refs/heads/main" || echo "::warning::Seeding from target main skipped (fetch failed or branch missing)" + if ! git fetch --no-tags source "+refs/heads/${branch_name}:refs/heads/${branch_name}"; then + echo "::error::Failed to fetch branch '${branch_name}' from source repo (fallback without shallow-exclude)" + notify_status "error" "${repo_name}" "${branch_name}" "${backup_mode}" "${start_epoch}" "source fetch 오류(폴백)" + cd "${ROOT_DIR}" + rm -rf "${CLONE_DIR}" + return + fi + else + echo "::error::Failed to fetch branch '${branch_name}' from source repo" + notify_status "error" "${repo_name}" "${branch_name}" "${backup_mode}" "${start_epoch}" "source fetch 오류" + cd "${ROOT_DIR}" + rm -rf "${CLONE_DIR}" + return + fi fi if [[ "${SYNC_TAGS}" == "true" ]]; then echo "Fetching tags from source..." diff --git a/README.md b/README.md index 08ece54..d0a20ab 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ 5) 기존 존재: 빈 bare 저장소 init → 타겟 `main` 커밋을 shallow-exclude로 지정해 소스 브랜치만 fetch → `main`으로 강제 푸시 6) 태그 동기화가 켜져 있으면 태그 fetch/push(강제+prune) 7) 기본 브랜치를 `main`으로 패치, 임시 디렉터리 정리 +8) 소스 서버가 `--shallow-exclude`를 지원하지 않으면 타겟 `main`을 얕게(depth=50) 받아 시드한 뒤 일반 fetch로 재시도 ## 알림 - `NOTIFY_WEBHOOK` 설정 시 시작/성공/실패/건너뛰기 상태를 KST 타임스탬프와 소요시간, 모드(신규/증분)와 함께 전송 diff --git a/to-do.md b/to-do.md index a7079f6..cce67ac 100644 --- a/to-do.md +++ b/to-do.md @@ -26,3 +26,4 @@ 2025-12-16 18:20:26 KST 추가 업데이트: 증분 fetch 시 타겟 main 커밋을 shallow-exclude로 지정해 필요한 부분만 받아오도록 변경, README 동작 개요에 반영. 2025-12-16 18:29:58 KST 추가 업데이트: SEED_FROM_TARGET 옵션과 타겟 main 선-fetch 시드를 제거하고 shallow-exclude 기반 증분 fetch만 유지하여 증분 로직을 단순화. 2025-12-17 08:27:54 KST 추가 업데이트: 스케줄 cron을 UTC 기준임을 명시하고 02:07 KST 실행을 위해 `7 17 * * *`로 설정, 동기화 결과 요약(총/성공/건너뜀/오류) 메시지를 마지막에 출력하고 알림 웹훅으로 전송하도록 추가. +2025-12-17 08:35:58 KST 추가 업데이트: 소스 서버가 `--shallow-exclude`를 지원하지 않을 때 타겟 main을 depth=50으로 시드한 후 일반 fetch로 재시도하도록 폴백을 추가, README 동작 개요 반영.