33 lines
686 B
Bash
Executable File
33 lines
686 B
Bash
Executable File
#!/usr/bin/env sh
|
|
|
|
set -eu
|
|
|
|
base_sha="${1:-}"
|
|
head_sha="${2:-HEAD}"
|
|
|
|
if [ -z "$base_sha" ] || printf '%s' "$base_sha" | grep -Eq '^0+$'; then
|
|
echo 'Impossible de déterminer le commit de référence.'
|
|
exit 1
|
|
fi
|
|
|
|
git cat-file -e "$base_sha^{commit}"
|
|
git cat-file -e "$head_sha^{commit}"
|
|
|
|
violations="$(
|
|
git diff \
|
|
--name-status \
|
|
--diff-filter=MDTR \
|
|
"$base_sha" \
|
|
"$head_sha" \
|
|
-- database/migrations/
|
|
)"
|
|
|
|
if [ -n "$violations" ]; then
|
|
echo 'Les migrations existantes sont immuables.'
|
|
echo 'Crée une nouvelle migration corrective :'
|
|
printf '%s\n' "$violations"
|
|
exit 1
|
|
fi
|
|
|
|
echo 'Aucune migration existante modifiée.'
|