chore(ci): tighten migration pattern and fail if base SHA missing
This commit is contained in:
@@ -18,7 +18,12 @@ if [ -z "$BASE_SHA" ] || [ -z "$HEAD_SHA" ]; then
|
||||
fi
|
||||
|
||||
# Ensure base is present in shallow clones.
|
||||
# NOTE: fetch may fail due to fetch-depth/ref settings; validate the commit exists after fetch.
|
||||
git fetch --no-tags --depth=1 origin "$BASE_SHA" || true
|
||||
if ! git cat-file -e "${BASE_SHA}^{commit}" 2>/dev/null; then
|
||||
echo "Base commit '$BASE_SHA' not found locally even after fetch. Check checkout fetch-depth / ref configuration."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Only count *newly added* migration files. Modified/deleted migrations should not trip this gate.
|
||||
# See review thread: https://github.com/abhi1693/openclaw-mission-control/pull/136#discussion_r2807812935
|
||||
@@ -28,7 +33,9 @@ if [ -z "$ADDED_FILES" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
MIGRATIONS=$(echo "$ADDED_FILES" | grep -E '^backend/migrations/versions/.*\.py$' || true)
|
||||
# Be slightly strict: avoid counting non-migration python files (e.g. __init__.py).
|
||||
# Alembic versions typically look like: <hex_revision>_<slug>.py
|
||||
MIGRATIONS=$(echo "$ADDED_FILES" | grep -E '^backend/migrations/versions/[0-9a-f]+_.*\.py$' || true)
|
||||
COUNT=$(echo "$MIGRATIONS" | sed '/^$/d' | wc -l | tr -d ' ')
|
||||
|
||||
if [ "$COUNT" -le 1 ]; then
|
||||
|
||||
Reference in New Issue
Block a user