mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Each time we update the clang toolchain, we've needed to deal with diffs resulting from new clang-format defaults and improvements to existing settings. This reduces diff checking to just the diffed lines.
28 lines
598 B
Bash
Executable File
28 lines
598 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
echo "Checking formatting..."
|
|
|
|
case "$(uname -s)" in
|
|
Darwin)
|
|
OS="mac-x64"
|
|
;;
|
|
Linux)
|
|
OS="linux-x64"
|
|
;;
|
|
*)
|
|
echo "Unknown operating system."
|
|
exit -1
|
|
;;
|
|
esac
|
|
|
|
CLANG_FORMAT="../buildtools/$OS/clang/bin/clang-format"
|
|
$CLANG_FORMAT --version
|
|
CLANG_FORMAT_DIFF="../buildtools/$OS/clang/share/clang/clang-format-diff.py"
|
|
|
|
DIFFS="$(git diff -U0 --no-color master | "$CLANG_FORMAT_DIFF" -p1 -binary "$CLANG_FORMAT")"
|
|
if [[ ! -z "$DIFFS" ]]; then
|
|
echo ""
|
|
echo "ERROR: Some files are formatted incorrectly. To fix, apply diffs below:"
|
|
echo "$DIFFS"
|
|
fi
|