Skip to content

Commit 8cfcf4f

Browse files
committed
check path contain space
1 parent d2d45ec commit 8cfcf4f

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

tools/ci/check_validate.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,21 @@ function prepare_paddle_env() {
5454

5555
function check_torch_validation() {
5656
LOG "[INFO] Start run validate for changed torch samples ..."
57+
58+
mapfile -t MODIFIED_FILES < <(git diff --name-only develop | grep -E "\bpaddle_samples\b/(.*\.py|.*\.json)")
59+
for file in "${MODIFIED_FILES[@]}"; do
60+
if [[ "${file}" == *" "* ]]; then
61+
LOG "[FATAL] File path contains spaces, which is not allowed. Please rename the file or directory."
62+
LOG "[FATAL] Offending path: '${file}'"
63+
exit 1
64+
fi
65+
done
66+
5767
MODIFIED_MODEL_PATHS=()
58-
for file in $(git diff --name-only develop | grep -E "\bsamples\b/(.*\.py|.*\.json)")
68+
for file in "${MODIFIED_FILES[@]}"
5969
do
6070
LOG "[INFO] Found ${file} modified."
61-
model_path=$(dirname ${file})
71+
model_path=$(dirname "${file}")
6272
MODIFIED_MODEL_PATHS[${#MODIFIED_MODEL_PATHS[@]}]=$model_path
6373
done
6474
MODIFIED_MODEL_PATHS=($(echo ${MODIFIED_MODEL_PATHS[@]} | tr ' ' '\n' | sort | uniq))
@@ -86,9 +96,17 @@ function check_torch_validation() {
8696

8797
function check_paddle_validation() {
8898
LOG "[INFO] Start run validate for changed paddle samples ..."
99+
mapfile -t MODIFIED_FILES < <(git diff --name-only develop | grep -E "\bpaddle_samples\b/(.*\.py|.*\.json)")
100+
for file in "${MODIFIED_FILES[@]}"; do
101+
if [[ "${file}" == *" "* ]]; then
102+
LOG "[FATAL] File path contains spaces, which is not allowed. Please rename the file or directory."
103+
LOG "[FATAL] Offending path: '${file}'"
104+
exit 1
105+
fi
106+
done
107+
89108
MODIFIED_MODEL_PATHS=()
90-
for file in $(git diff --name-only develop | grep -E "\bpaddle_samples\b/(.*\.py|.*\.json)")
91-
do
109+
for file in "${MODIFIED_FILES[@]}"
92110
LOG "[INFO] Found ${file} modified."
93111
model_path=$(dirname ${file})
94112
MODIFIED_MODEL_PATHS[${#MODIFIED_MODEL_PATHS[@]}]=$model_path

0 commit comments

Comments
 (0)