From 4d3acfdcd317376536b97d9ed34e63e072fe60c0 Mon Sep 17 00:00:00 2001 From: Cloud <895682100@qq.com> Date: Fri, 14 Aug 2026 16:37:53 +0800 Subject: [PATCH] fix star history fallback on fetch errors Fail when the remote branch check fails; use the seed only when the branch does not exist. --- .github/workflows/update-star-history.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-star-history.yml b/.github/workflows/update-star-history.yml index 10463a1a..2a88d93e 100644 --- a/.github/workflows/update-star-history.yml +++ b/.github/workflows/update-star-history.yml @@ -38,9 +38,15 @@ jobs: history_dir="$RUNNER_TEMP/star-history" mkdir -p "$history_dir" - if git fetch --quiet --depth=1 origin refs/heads/star-history; then + if git ls-remote --quiet --exit-code --heads origin refs/heads/star-history > /dev/null; then + git fetch --quiet --depth=1 origin refs/heads/star-history git show FETCH_HEAD:star-history.json > "$history_dir/star-history.json" else + remote_status=$? + if [[ "$remote_status" -ne 2 ]]; then + echo "Failed to check the remote star-history branch." >&2 + exit "$remote_status" + fi cp .github/data/star-history.json "$history_dir/star-history.json" fi