From b92f5f6caa8a3d92594574201c106bdf7c75ecbc Mon Sep 17 00:00:00 2001 From: Lectom C Han Date: Wed, 17 Dec 2025 08:38:11 +0900 Subject: [PATCH] =?UTF-8?q?=EC=84=BC=ED=84=B0Git=20=EB=B2=84=EC=A0=84?= =?UTF-8?q?=EC=9D=B4=20=EB=82=AE=EC=95=84,=20--shallow-exclude=20=EC=A7=80?= =?UTF-8?q?=EC=9B=90=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EA=B2=BD?= =?UTF-8?q?=EC=9A=B0=20=EC=96=95=EC=9D=80=20=EB=B3=B5=EC=82=AC=EB=A1=9C=20?= =?UTF-8?q?=EC=9A=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/mirror.yml | 23 ++++++++++++++++++----- README.md | 1 + to-do.md | 1 + 3 files changed, 20 insertions(+), 5 deletions(-) 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 동작 개요 반영.