build(migration): push之前校验migration multiple head

This commit is contained in:
sophie committed 2026-06-23 13:37:30 +08:00
1 parent 1bc938155a
commit 2aa8609c17
3 files changed
+53 -8

No files matched your search

+16 -2
View File
@@ -5,11 +5,12 @@ ROOT_DIR="$(git rev-parse --show-toplevel)"
# shellcheck source=_common.sh
source "${ROOT_DIR}/.githooks/_common.sh"
if hook_should_skip; then
if [[ "${SKIP_GIT_HOOKS:-}" == "1" ]]; then
exit 0
fi
zero="0000000000000000000000000000000000000000"
need_migration_check=0
need_frontend_build=0
while read -r local_ref local_sha remote_ref remote_sha; do
@@ -33,12 +34,25 @@ while read -r local_ref local_sha remote_ref remote_sha; do
changed_files="$(git diff --name-only --diff-filter=ACMR "${remote_sha}" "${local_sha}" || true)"
fi
if echo "${changed_files}" | grep -qE '^backend/migrations/versions/.*\.py$'; then
need_migration_check=1
fi
if frontend_paths_in "${changed_files}"; then
need_frontend_build=1
break
fi
done
if [[ "${need_migration_check}" -eq 1 ]]; then
if ! run_migration_heads_check "${ROOT_DIR}"; then
exit 1
fi
fi
if [[ "${SKIP_FRONTEND_HOOKS:-}" == "1" ]]; then
exit 0
fi
if [[ "${need_frontend_build}" -eq 0 ]]; then
exit 0
fi