forked from moveit/moveit_ci
-
Notifications
You must be signed in to change notification settings - Fork 1
/
check_clang_format.sh
34 lines (27 loc) · 1.14 KB
/
check_clang_format.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Software License Agreement - BSD 3-Clause License
#
# Author: Dave Coleman
travis_fold start clang.format "Running clang-format check"
travis_run_simple --display "cd to repository source: $CI_SOURCE_PATH" cd $CI_SOURCE_PATH
# Install Dependencies
travis_run apt-get -qq install -y clang-format-3.9
# Ensure that a .clang-format config file is present, if not download from MoveIt
if [ ! -f .clang-format ]; then
travis_run --title "Fetching default clang-format config from MoveIt" \
wget -nv "https://raw.githubusercontent.com/ros-planning/moveit2/master/.clang-format"
fi
# Run clang-format
cmd="find . -name '*.h' -or -name '*.hpp' -or -name '*.cpp' | xargs clang-format-3.9 -i -style=file"
travis_run --display "Running clang-format${ANSI_RESET}\\n$cmd" "$cmd"
# Check for changes in repo
travis_have_fixes
result=$?
# Finish fold before printing result summary
travis_fold end clang.format
if [ $result -eq 1 ] ; then
echo -e $(colorize GREEN "Passed clang-format check")
else
echo -e $(colorize RED "clang-format check failed. Open fold for details.")
echo -e "Run the following command to fix these issues:\\n$cmd"
exit 2
fi