From 257c1a91ed2399a4d2e37b5ee5f2dae3a0c7e0de Mon Sep 17 00:00:00 2001 From: User Date: Tue, 23 Dec 2025 20:28:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/autograde.yml | 37 ++++++++++++++-------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/.gitea/workflows/autograde.yml b/.gitea/workflows/autograde.yml index 85837c8..e1c05fa 100644 --- a/.gitea/workflows/autograde.yml +++ b/.gitea/workflows/autograde.yml @@ -123,31 +123,24 @@ jobs: HOST=$(echo "${{ github.server_url }}" | sed 's|https\?://||' | cut -d'/' -f1) fi - # 尝试使用课程主组织获取测试仓库 - # 如果测试仓库在学生组织中不存在,可能在课程组织中 - # 使用空格分隔的字符串替代bash数组,以提高兼容性 - POTENTIAL_ORGS="vibevault-course course-assets vibevault-main final-vibevault" + ORG=$(echo "${{ github.repository }}" | cut -d'/' -f1) + REPO_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2) - # 直接使用正确的测试仓库名 - ASSIGNMENT_ID="final-vibevault" + # Extract assignment ID + if echo "$REPO_NAME" | grep -q -- '-stu_'; then + ASSIGNMENT_ID=$(echo "$REPO_NAME" | sed 's/-stu_.*//') + elif echo "$REPO_NAME" | grep -q -- '-template'; then + ASSIGNMENT_ID=$(echo "$REPO_NAME" | sed 's/-template.*//') + else + ASSIGNMENT_ID="final-vibevault" + fi - # 尝试从多个可能的组织中克隆测试仓库 - for COURSE_ORG in $POTENTIAL_ORGS; do - echo "📥 Trying to fetch tests from ${COURSE_ORG}/${ASSIGNMENT_ID}-tests..." - - AUTH_URL="http://${TESTS_USERNAME}:${TESTS_TOKEN}@${HOST}/${COURSE_ORG}/${ASSIGNMENT_ID}-tests.git" - - if git -c http.sslVerify=false clone --depth=1 "$AUTH_URL" _priv_tests 2>&1; then - echo "✅ Successfully cloned ${COURSE_ORG}/${ASSIGNMENT_ID}-tests!" - break - else - echo "❌ Failed to clone from ${COURSE_ORG}, trying next organization..." - fi - done + echo "📥 Fetching tests and grading scripts from ${ORG}/${ASSIGNMENT_ID}-tests..." - # 检查是否成功克隆了测试仓库 - if [ ! -d "_priv_tests" ]; then - echo "❌ Failed to clone ${ASSIGNMENT_ID}-tests repository from any organization!" + AUTH_URL="http://${TESTS_USERNAME}:${TESTS_TOKEN}@${HOST}/${ORG}/${ASSIGNMENT_ID}-tests.git" + + if ! git -c http.sslVerify=false clone --depth=1 "$AUTH_URL" _priv_tests 2>&1; then + echo "❌ Failed to clone ${ASSIGNMENT_ID}-tests repository!" exit 1 fi