Skip to content

Commit 6adb7bf

Browse files
committed
fix(workflow): robust data branch fetch after force-push
Use explicit refspec for git fetch so origin/data tracking ref is always created. Replace rev-parse with actual file-existence check so force-pushed branches with different history are detected.
1 parent 2b5e9f2 commit 6adb7bf

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

.github/workflows/check.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ jobs:
6565
- name: Fetch database from data branch
6666
run: |
6767
mkdir -p data
68-
git fetch origin data --depth=1 2>/dev/null || echo "No data branch yet."
69-
if ! git rev-parse origin/data >/dev/null 2>&1; then
70-
echo "No data branch, starting fresh."
71-
exit 0
72-
fi
68+
git fetch --depth=1 origin refs/heads/data:refs/remotes/origin/data 2>/dev/null \
69+
|| { echo "No data branch, starting fresh."; exit 0; }
70+
git show origin/data:data/icourse-index.enc >/dev/null 2>&1 \
71+
|| git show origin/data:data/icourse.db.gz.enc >/dev/null 2>&1 \
72+
|| git show origin/data:data/icourse.db.enc >/dev/null 2>&1 \
73+
|| { echo "No database found on data branch, starting fresh."; exit 0; }
7374
# Prefer the sharded layout (current).
7475
if git cat-file -e origin/data:data/icourse-index.enc 2>/dev/null; then
7576
mkdir -p data/sharded/shards

.github/workflows/single_run.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ jobs:
6767
- name: Fetch database from data branch
6868
run: |
6969
mkdir -p data
70-
git fetch origin data --depth=1 2>/dev/null || echo "No data branch yet."
71-
if ! git rev-parse origin/data >/dev/null 2>&1; then
72-
echo "No data branch, starting fresh."
73-
exit 0
74-
fi
70+
git fetch --depth=1 origin refs/heads/data:refs/remotes/origin/data 2>/dev/null \
71+
|| { echo "No data branch, starting fresh."; exit 0; }
72+
git show origin/data:data/icourse-index.enc >/dev/null 2>&1 \
73+
|| git show origin/data:data/icourse.db.gz.enc >/dev/null 2>&1 \
74+
|| git show origin/data:data/icourse.db.enc >/dev/null 2>&1 \
75+
|| { echo "No database found on data branch, starting fresh."; exit 0; }
7576
if git cat-file -e origin/data:data/icourse-index.enc 2>/dev/null; then
7677
mkdir -p data/sharded/shards
7778
git show origin/data:data/icourse-index.enc > data/sharded/icourse-index.enc

0 commit comments

Comments
 (0)