From aa5cc8bb9ff01563dbf5775790e7d8850eed9323 Mon Sep 17 00:00:00 2001 From: Lectom C Han Date: Tue, 16 Dec 2025 18:33:48 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A6=9D=EB=B6=84=EB=B0=B1=EC=97=85=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EA=B0=9C=EC=84=A0,=20shallow=5Fexclude=20?= =?UTF-8?q?=EC=98=B5=EC=85=98=20=ED=99=9C=EC=9A=A9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/mirror.yml | 12 ++++++------ README.md | 4 ++-- to-do.md | 5 +++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/mirror.yml b/.gitea/workflows/mirror.yml index 251e4bb..9eba709 100644 --- a/.gitea/workflows/mirror.yml +++ b/.gitea/workflows/mirror.yml @@ -13,7 +13,7 @@ on: jobs: mirror: runs-on: [internal] - timeout-minutes: 360 # 6 hours timeout + timeout-minutes: 500 steps: - name: Checkout uses: actions/checkout@v4 @@ -216,6 +216,10 @@ jobs: return fi fi + shallow_exclude_args=() + if ${repo_exists} && [[ -n "${target_commit:-}" ]]; then + shallow_exclude_args=(--shallow-exclude="${target_commit}") + fi # Create a temporary directory for cloning CLONE_DIR=$(mktemp -d) @@ -242,14 +246,10 @@ jobs: fi git remote add origin "${GITEA_REMOTE}" git remote add source "${source_repo_url}" - echo "Seeding objects from target main for delta fetch..." - if ! git fetch --no-tags origin "+refs/heads/main:refs/heads/main"; then - echo "::warning::Failed to fetch target main; continuing without seed" - fi fi echo "Fetching latest branch '${branch_name}' from source..." - if ! git fetch --no-tags source "+refs/heads/${branch_name}:refs/heads/${branch_name}"; then + 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}" diff --git a/README.md b/README.md index 0f1ff97..e4aca12 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ - 브랜치마다 대응 저장소명을 결정해 `main` 브랜치로 강제 푸시하며, 태그 동기화 옵션을 제공합니다. ## 실행 환경 -- Runner 라벨: `internal` (워크플로우는 이 라벨을 가진 러너에서만 동작) +- Runner 라벨: `internal` (해당 라벨이 있는 셀프호스티드 러너에서만 실행) - 예약 실행: 매일 02:07 KST (`cron: 7 2 * * *`) - 수동 실행: `workflow_dispatch` 입력을 통해 선택 브랜치만 실행 가능 @@ -39,7 +39,7 @@ 2) 타겟 저장소 존재 확인/생성 (`default_branch=main`) 3) 커밋 동일 시 skip (알림 전송) 4) 신규 생성: 소스 브랜치를 bare single-branch clone 후 `main`으로 강제 푸시 -5) 기존 존재: 빈 bare 저장소 init → 타겟 `main` 선-fetch로 객체 시드 → 소스 브랜치만 fetch → `main`으로 강제 푸시 +5) 기존 존재: 빈 bare 저장소 init → 타겟 `main` 커밋을 shallow-exclude로 지정해 소스 브랜치만 fetch → `main`으로 강제 푸시 6) 태그 동기화가 켜져 있으면 태그 fetch/push(강제+prune) 7) 기본 브랜치를 `main`으로 패치, 임시 디렉터리 정리 diff --git a/to-do.md b/to-do.md index 6b883d3..9b828c4 100644 --- a/to-do.md +++ b/to-do.md @@ -20,3 +20,8 @@ 2025-12-16 13:28:01 KST 추가 업데이트: mirror.yml에 branch_list 주석(`#`) 스킵 및 `sourceRepo/branch,alias` 구문을 추가해, 콤마 뒤의 별도 저장소 이름(alias)으로 타겟을 지정할 수 있도록 개선. 2025-12-16 14:03:18 KST 추가 업데이트: mirror.yml에 태그 동기화 옵션(SYNC_TAGS, 기본 true) 추가. 소스 태그를 fetch --prune/--prune-tags 후 타겟으로 push --force --prune해 태그를 미러링하도록 개선하며, 태그 동기화 실패 시 알림을 보냄. 2025-12-16 16:16:39 KST 추가 업데이트: README.md 작성(목적/사용법/입력 규칙/시크릿/러너 조건/태그 옵션 등). mirror.yml의 cron을 매일 02:07 KST로 조정하고 runs-on 라벨을 `internal`로 제한. +2025-12-16 17:59:05 KST 추가 업데이트: mirror.yml에 runner_label 입력 및 RUNNER_LABEL 변수 기반 실행러너 선택 로직 추가(없으면 ubuntu-latest 사용), README에 러너 지정 방법 반영. +2025-12-16 18:10:22 KST 추가 업데이트: runner 설정을 다시 `runs-on: [internal]`로 고정한 상태에 맞춰 README 실행 환경 설명을 internal 러너 기준으로 롤백 정리. +2025-12-16 18:16:34 KST 추가 업데이트: 증분 성능 검토를 위해 타겟 main 선-fetch를 켜고 끄기 위한 SEED_FROM_TARGET 옵션(기본 false) 추가. README에 옵션 설명 반영. +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만 유지하여 증분 로직을 단순화.