all.bash: add a check for abnormal migrations files

This catches the case where a rebase resulted in overlapping sequence
numbers.

Change-Id: I07e0a3729fabbbef895fae079ff70e8862201cd2
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/460456
Reviewed-by: Julie Qiu <julieqiu@google.com>
This commit is contained in:
Rob Findley 2019-05-06 22:23:30 -04:00 коммит произвёл Julie Qiu
Родитель 27bbac7ffe
Коммит 17386b461f
1 изменённых файлов: 13 добавлений и 2 удалений

Просмотреть файл

@ -58,11 +58,22 @@ findcode() {
# Check that all .go and .sql files that have been staged in this commit have a
# license header.
info "Running: Checking staged files for license header"
info "Checking staged files for license header"
checkheaders $(git diff --cached --name-only | grep -E ".go$|.sql$")
info "Running: Checking internal files for license header"
info "Checking internal files for license header"
checkheaders $(findcode)
# Find migrations with bad sequence numbers, possibly resulting from a bad merge
bad_migrations() {
ls migrations | cut -d _ -f 1 | sort | uniq -c | grep -vE '^\s+2 '
}
info "Checking for bad migrations"
bad_migrations | while read line
do
err "unexpected number of migrations: $line"
done
# Download staticcheck if it doesn't exist
if ! [ -x "$(command -v staticcheck)" ]; then
info "Running: go get -u honnef.co/go/tools/cmd/staticcheck"