Enable the base branch to be overridden in the code format check script (#2607)

Default to master.

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
This commit is contained in:
Kévin Petit 2019-05-24 19:33:43 +01:00 коммит произвёл Steven Perron
Родитель b8fe7211c4
Коммит 4c73ebc46f
1 изменённых файлов: 4 добавлений и 2 удалений

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

@ -18,14 +18,16 @@
#
# This script assumes to be invoked at the project root directory.
FILES_TO_CHECK=$(git diff --name-only master | grep -E ".*\.(cpp|cc|c\+\+|cxx|c|h|hpp)$")
BASE_BRANCH=${1:-master}
FILES_TO_CHECK=$(git diff --name-only ${BASE_BRANCH} | grep -E ".*\.(cpp|cc|c\+\+|cxx|c|h|hpp)$")
if [ -z "${FILES_TO_CHECK}" ]; then
echo "No source code to check for formatting."
exit 0
fi
FORMAT_DIFF=$(git diff -U0 master -- ${FILES_TO_CHECK} | python ./utils/clang-format-diff.py -p1 -style=file)
FORMAT_DIFF=$(git diff -U0 ${BASE_BRANCH} -- ${FILES_TO_CHECK} | python ./utils/clang-format-diff.py -p1 -style=file)
if [ -z "${FORMAT_DIFF}" ]; then
echo "All source code in PR properly formatted."