Skip to content

Commit 7fdbbce

Browse files
authored
Add Warning To fix_formatting.sh Script When Using -a Argument (UBC-Thunderbots#926)
* added wanrning to fix_format script * formatting the formatter * fixed indenting
1 parent 195680e commit 7fdbbce

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

clang_format/fix_formatting.sh

+26-15
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,34 @@ while test $# -gt 0; do
5454
exit 0
5555
;;
5656
-a|--all)
57-
echo "Formatting all files..."
57+
echo "WARNING: "-a" will format all the files and can be very slow! Please consider using "-b" instead!"
58+
echo "Are you sure you want to format all files (y/n)?"
59+
read continueFormat
5860

59-
# Generate extension string
60-
# Formatted as -iname *.EXTENSION -o
61-
EXTENSION_STRING=""
62-
for value in "${EXTENSIONS[@]}"
63-
do
64-
EXTENSION_STRING="$EXTENSION_STRING -iname *.$value -o"
65-
done
66-
67-
# Find all the files that we want to format, and pass them to
68-
# clang-format as arguments
69-
# We remove the last -o flag from the extension string
70-
find $CURR_DIR/../src/ ${EXTENSION_STRING::-2} \
71-
| xargs $CURR_DIR/clang-format-$CLANG_VERSION -i -style=file
61+
if [ "$continueFormat" == "n" ]; then
62+
exit 0
7263

73-
shift
64+
elif [ "$continueFormat" == "y" ]; then
65+
echo "Formatting all files..."
66+
67+
# Generate extension string
68+
# Formatted as -iname *.EXTENSION -o
69+
EXTENSION_STRING=""
70+
for value in "${EXTENSIONS[@]}"
71+
do
72+
EXTENSION_STRING="$EXTENSION_STRING -iname *.$value -o"
73+
done
74+
75+
# Find all the files that we want to format, and pass them to
76+
# clang-format as arguments
77+
# We remove the last -o flag from the extension string
78+
find $CURR_DIR/../src/ ${EXTENSION_STRING::-2} \
79+
| xargs $CURR_DIR/clang-format-$CLANG_VERSION -i -style=file
80+
shift
81+
else
82+
echo "Error: input not recognized"
83+
exit 1
84+
fi
7485
;;
7586
-b|--branch)
7687
# Shift the arguents to check for the argument to this flag

0 commit comments

Comments
 (0)