백업 레포 내용이 동일하면 Skip
This commit is contained in:
@@ -52,6 +52,11 @@ jobs:
|
||||
start)
|
||||
text="센터Git ${repo} 백업을 ${ts}에 시작합니다. (branch: ${branch}, mode: ${mode})"
|
||||
;;
|
||||
skip)
|
||||
end_epoch=$(date +%s)
|
||||
duration=$((end_epoch - start_epoch))
|
||||
text="센터Git ${repo} 백업을 건너뜁니다. (branch: ${branch} -> main, mode: ${mode}, duration: ${duration}s, 시각: ${ts})"
|
||||
;;
|
||||
success)
|
||||
end_epoch=$(date +%s)
|
||||
duration=$((end_epoch - start_epoch))
|
||||
@@ -142,6 +147,7 @@ jobs:
|
||||
notify_status "error" "${repo_name}" "${branch_name}" "${backup_mode}" "${start_epoch}" "source branch 없음/비어 있음"
|
||||
return
|
||||
fi
|
||||
branch_commit=$(echo "${branch_ref}" | awk '{print $1}')
|
||||
|
||||
# Check if repository exists on Gitea
|
||||
repo_exists=false
|
||||
@@ -180,6 +186,17 @@ jobs:
|
||||
GITEA_HOSTNAME=$(echo "${BASE_GITEA_URL}" | sed -e 's~^https*://~~' -e 's~/$~~')
|
||||
GITEA_REMOTE="https://${BASE_GITEA_USER}:${BASE_GITEA_TOKEN}@${GITEA_HOSTNAME}/${CENTER_ORG}/${repo_name}.git"
|
||||
|
||||
# If target repo exists and refs match, skip heavy operations
|
||||
if ${repo_exists}; then
|
||||
target_main_ref=$(git ls-remote "${GITEA_REMOTE}" "refs/heads/main" || true)
|
||||
target_commit=$(echo "${target_main_ref}" | awk '{print $1}')
|
||||
if [[ -n "${branch_commit:-}" && -n "${target_commit}" && "${branch_commit}" == "${target_commit}" ]]; then
|
||||
echo "Target main already at source commit (${branch_commit}). Skipping clone/push."
|
||||
notify_status "skip" "${repo_name}" "${branch_name}" "${backup_mode}" "${start_epoch}"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create a temporary directory for cloning
|
||||
CLONE_DIR=$(mktemp -d)
|
||||
echo "Working directory: ${CLONE_DIR}"
|
||||
|
||||
Reference in New Issue
Block a user