This commit is contained in:
@@ -151,6 +151,7 @@ jobs:
|
||||
|
||||
# Check if repository exists on Gitea
|
||||
repo_exists=false
|
||||
just_created=false
|
||||
http_status=$(curl -s -o /dev/null -w "%{http_code}" -H "${AUTH_HEADER}" "${BASE_GITEA_URL}/api/v1/repos/${CENTER_ORG}/${repo_name}")
|
||||
|
||||
if [ "${http_status}" == "404" ]; then
|
||||
@@ -166,6 +167,7 @@ jobs:
|
||||
fi
|
||||
echo "Repository created successfully."
|
||||
repo_exists=true
|
||||
just_created=true
|
||||
rm -f "${create_tmp}"
|
||||
elif [ "${http_status}" != "200" ]; then
|
||||
echo "::error::Error checking repository. HTTP status: ${http_status}"
|
||||
@@ -175,7 +177,9 @@ jobs:
|
||||
echo "Repository 'center_dev/${repo_name}' already exists."
|
||||
repo_exists=true
|
||||
fi
|
||||
if ${repo_exists}; then
|
||||
if ${just_created}; then
|
||||
backup_mode="신규 전체 백업"
|
||||
elif ${repo_exists}; then
|
||||
backup_mode="증분 업데이트 (pull/fetch)"
|
||||
else
|
||||
backup_mode="신규 전체 백업"
|
||||
@@ -200,20 +204,9 @@ jobs:
|
||||
# Create a temporary directory for cloning
|
||||
CLONE_DIR=$(mktemp -d)
|
||||
echo "Working directory: ${CLONE_DIR}"
|
||||
|
||||
if ${repo_exists}; then
|
||||
echo "Cloning existing target repository for update (bare)..."
|
||||
if ! git clone --bare "${GITEA_REMOTE}" "${CLONE_DIR}"; then
|
||||
echo "::error::Failed to clone existing target repository ${GITEA_REMOTE}"
|
||||
notify_status "error" "${repo_name}" "${branch_name}" "${backup_mode}" "${start_epoch}" "target clone 실패"
|
||||
rm -rf "${CLONE_DIR}"
|
||||
return
|
||||
fi
|
||||
cd "${CLONE_DIR}"
|
||||
git remote add source "${source_repo_url}"
|
||||
else
|
||||
echo "Cloning source repository for first-time push (bare)..."
|
||||
if ! git clone --bare "${source_repo_url}" "${CLONE_DIR}"; then
|
||||
if ${just_created}; then
|
||||
echo "Target repo newly created; cloning source branch for initial push..."
|
||||
if ! git clone --bare --no-tags --single-branch --branch "${branch_name}" "${source_repo_url}" "${CLONE_DIR}"; then
|
||||
echo "::error::Failed to clone source repository ${source_repo_url}"
|
||||
notify_status "error" "${repo_name}" "${branch_name}" "${backup_mode}" "${start_epoch}" "source clone 실패"
|
||||
rm -rf "${CLONE_DIR}"
|
||||
@@ -222,10 +215,21 @@ jobs:
|
||||
cd "${CLONE_DIR}"
|
||||
git remote rename origin source
|
||||
git remote add origin "${GITEA_REMOTE}"
|
||||
else
|
||||
cd "${CLONE_DIR}"
|
||||
if ! git init --bare; then
|
||||
echo "::error::Failed to init bare repository"
|
||||
notify_status "error" "${repo_name}" "${branch_name}" "${backup_mode}" "${start_epoch}" "bare init 실패"
|
||||
cd "${ROOT_DIR}"
|
||||
rm -rf "${CLONE_DIR}"
|
||||
return
|
||||
fi
|
||||
git remote add origin "${GITEA_REMOTE}"
|
||||
git remote add source "${source_repo_url}"
|
||||
fi
|
||||
|
||||
echo "Fetching latest branch '${branch_name}' from source..."
|
||||
if ! git fetch source "+refs/heads/${branch_name}:refs/heads/${branch_name}"; then
|
||||
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"
|
||||
notify_status "error" "${repo_name}" "${branch_name}" "${backup_mode}" "${start_epoch}" "source fetch 오류"
|
||||
cd "${ROOT_DIR}"
|
||||
|
||||
Reference in New Issue
Block a user