diff --git a/.gitea/ci/bootstrap_workspace.sh b/.gitea/ci/bootstrap_workspace.sh index f4b2040..8a0c153 100644 --- a/.gitea/ci/bootstrap_workspace.sh +++ b/.gitea/ci/bootstrap_workspace.sh @@ -128,7 +128,7 @@ create_job_workspace_from_mirror() { rm -rf "${job_workspace}" mkdir -p "${job_workspace}" - git clone --local "${mirror_path}" "${repo_dir}" >/dev/null + git clone --shared "${mirror_path}" "${repo_dir}" >/dev/null git -C "${repo_dir}" remote set-url origin "${remote_url}" } diff --git a/tests/workspace_helper_test.sh b/tests/workspace_helper_test.sh index 0518657..ce25081 100644 --- a/tests/workspace_helper_test.sh +++ b/tests/workspace_helper_test.sh @@ -71,7 +71,7 @@ test_repo_owner_and_name_parsing() { test_prepare_and_cleanup_workspace() { local temp_root remote_repo seed_repo mirror_root workspace_root env_file - local repo_dir mirror_path job_workspace origin_url + local repo_dir mirror_path job_workspace origin_url alternates_file alternates_target temp_root=$(mktemp -d) remote_repo="${temp_root}/remote.git" @@ -117,6 +117,15 @@ test_prepare_and_cleanup_workspace() { origin_url=$(git -C "${repo_dir}" remote get-url origin) assert_eq "${remote_repo}" "${origin_url}" "prepared repo should point origin to the requested remote" + alternates_file="${repo_dir}/.git/objects/info/alternates" + if [ ! -f "${alternates_file}" ]; then + echo "FAIL: prepared repo should use shared mirror objects via alternates" >&2 + exit 1 + fi + + alternates_target=$(cat "${alternates_file}") + assert_eq "${mirror_path}/objects" "${alternates_target}" "prepared repo should borrow objects from the bare mirror" + cleanup_job_workspace "${job_workspace}" if [ -e "${job_workspace}" ]; then