#!/usr/bin/env bash
#
# SPDX-FileCopyrightText: 2023 Wiktor Kwapisiewicz <wiktor@metacode.biz>
# SPDX-License-Identifier: CC0-1.0

set -euxo pipefail

if ! git diff-files --quiet ; then
    echo "Working tree has changes. Please stage them: git add ."
    exit 1
fi

codespell --write-changes
cargo clippy --fix --allow-staged

# fmt must be last as clippy's changes may break formatting
cargo fmt
