| 1 |
#!/usr/bin/env bash |
| 2 |
|
| 3 |
# A script to check prettyness over the repository. |
| 4 |
|
| 5 |
# lint-commits.sh seeks to prevent the worsening of already present |
| 6 |
# problems, such as tab indentation in ml files. lint-repository.sh |
| 7 |
# also seeks to prevent the (re-)introduction of solved problems, such |
| 8 |
# as newlines at the end of .v files. |
| 9 |
|
| 10 |
CODE=0 |
| 11 |
|
| 12 |
# if COQ_CI_COLOR is set (from the environment) keep it intact (even when it's the empty string)' |
| 13 |
if ! [ "${COQ_CI_COLOR+1}" ]; then |
| 14 |
# NB: in CI TERM is unset in the environment |
| 15 |
# when TERM is unset, bash sets it to "dumb" as a bash variable (not exported?) |
| 16 |
if { [ -t 1 ] && ! [ "$TERM" = dumb ]; } || [ "$CI" ] |
| 17 |
then export COQ_CI_COLOR=1 |
| 18 |
else export COQ_CI_COLOR= |
| 19 |
fi |
| 20 |
fi |
| 21 |
|
| 22 |
if [[ $(git log -n 1 --pretty='format:%s') == "[CI merge]"* ]]; then |
| 23 |
# The second parent of bot merges is from the PR, the first is |
| 24 |
# current master |
| 25 |
head=$(git rev-parse HEAD^2) |
| 26 |
else |
| 27 |
head=$(git rev-parse HEAD) |
| 28 |
fi |
| 29 |
|
| 30 |
# We assume that all non-bot merge commits are from the main branch |
| 31 |
# For Rocq it is extremely rare for this assumption to be broken |
| 32 |
read -r base < <(git log -n 1 --merges --pretty='format:%H' "$head") |
| 33 |
|
| 34 |
dev/lint-commits.sh "$base" "$head" || CODE=1 |
| 35 |
|
| 36 |
# Check that the files with 'whitespace' gitattribute end in a newline. |
| 37 |
# xargs exit status is 123 if any file failed the test |
| 38 |
echo Checking end of file newlines |
| 39 |
find . "(" -path ./.git -prune ")" -o -type f -print0 | |
| 40 |
xargs -0 dev/tools/check-eof-newline.sh || CODE=1 |
| 41 |
|
| 42 |
echo Checking overlays |
| 43 |
dev/tools/check-overlays.sh || CODE=1 |
| 44 |
|
| 45 |
echo Checking CACHEKEY |
| 46 |
dev/tools/check-cachekey.sh || CODE=1 |
| 47 |
|
| 48 |
# Check that doc/tools/docgram/fullGrammar is up-to-date |
| 49 |
echo Checking grammar files |
| 50 |
make SHOW='@true ""' doc_gram_verify || CODE=1 |
| 51 |
|
| 52 |
exit $CODE |