-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit_copy.sh
More file actions
executable file
·100 lines (83 loc) · 2.81 KB
/
Copy pathpre-commit_copy.sh
File metadata and controls
executable file
·100 lines (83 loc) · 2.81 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
# File generated by pre-commit: https://pre-commit.com
# ID: 138fd403232d2ddd5efb44317e38bf03
# start templated
INSTALL_PYTHON=/usr/bin/python3
ARGS=(hook-impl --config=.pre-commit-config.yaml --hook-type=pre-commit)
# end templated
echo "|--------------------------------------------------------------|"
echo " git changes staged "
changed_files=$(git diff --name-only --ignore-submodules)
# Check if the output is empty
if [ -z "$changed_files" ]; then
echo -e "\n Ready for commit."
else
echo -e " Changes detected: $changed_files\n, please add [git add -A] them before committing."
exit 1
fi
echo "|--------------------------------------------------------------|"
echo " running ROS linting "
echo " Running ament_cpplint"
ament_cpplint src/ include/
if [ $? -ne 0 ]; then
echo "ament_cpplint failed"
exit 1
fi
echo " Running ament_xmllint"
ament_xmllint package.xml
if [ $? -ne 0 ]; then
echo "ament_xmllint failed"
exit 1
fi
echo " Running ament_flake8"
ament_flake8 scripts/ torque_vectoring_pkg/
if [ $? -ne 0 ]; then
echo "ament_flake8 failed"
exit 1
fi
echo " Running ament_pep257"
ament_pep257 scripts/ torque_vectoring_pkg/
if [ $? -ne 0 ]; then
echo "ament_pep257 failed"
exit 1
fi
echo "|--------------------------------------------------------------|"
echo " Running Rosdep"
rosdep check --from-paths . --ignore-src --rosdistro=jazzy
if [ $? -ne 0 ]; then
echo "rosdep failed"
exit 1
fi
echo "|--------------------------------------------------------------|"
echo " running C++ linting "
var_cpp=$(git diff --name-only --diff-filter=AM HEAD -- '*.cpp' '*.h')
if [ -z "$var_cpp" ]; then
echo "No changes in cpp files"
else
echo "Changes detected in cpp files: $var_cpp"
./tidy-code.sh
tidy_exit_code=$?
if [ "$tidy_exit_code" -eq 2 ]; then
echo "clang-tidy failed"
exit 1
fi
fi
echo "|--------------------------------------------------------------|"
echo " Interval "
echo "|--------------------------------------------------------------|"
echo -e "\n"
curl https://icanhazdadjoke.com/
echo -e "\n\n"
echo "|--------------------------------------------------------------|"
echo " Running pre-commit hooks "
echo "|--------------------------------------------------------------|"
HERE="$(cd "$(dirname "$0")" && pwd)"
ARGS+=(--hook-dir "$HERE" -- "$@")
if [ -x "$INSTALL_PYTHON" ]; then
exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}"
elif command -v pre-commit > /dev/null; then
exec pre-commit "${ARGS[@]}"
else
echo 'pre-commit not found. Did you forget to activate your virtualenv?' 1>&2
exit 1
fi