Skip to content

Commit 16bae86

Browse files
authored
Merge pull request #7 from DanielVoogsgerd/word_splitting
fix: Prevent word-splitting in user input
2 parents 25d1222 + 8656017 commit 16bae86

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

conventional-pre-commit.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
#!/usr/bin/env bash
22

33
# list of Conventional Commits types
4-
cc_types="feat fix"
5-
default_types="build chore ci docs $cc_types perf refactor revert style test"
6-
types=( $cc_types )
4+
cc_types=("feat" "fix")
5+
default_types=("build" "chore" "ci" "docs" "${cc_types[@]}" "perf" "refactor" "revert" "style" "test")
6+
types=( "${cc_types[@]}" )
77

88
if [ $# -eq 1 ]; then
9-
types=( $default_types )
9+
types=( "${default_types[@]}" )
1010
else
1111
# assume all args but the last are types
1212
while [ $# -gt 1 ]; do
13-
types+=( $1 )
13+
types+=( "$1" )
1414
shift
1515
done
1616
fi
1717

1818
# the commit message file is the last remaining arg
19-
msg_file=$1
19+
msg_file="$1"
2020

2121
# join types with | to form regex ORs
2222
r_types="($(IFS='|'; echo "${types[*]}"))"
@@ -34,7 +34,7 @@ if grep -Eq "$pattern" "$msg_file"; then
3434
exit 0
3535
fi
3636

37-
echo "[Commit message] $( cat $msg_file )"
37+
echo "[Commit message] $( cat "$msg_file" )"
3838
echo "
3939
Your commit message does not follow Conventional Commits formatting
4040
https://www.conventionalcommits.org/

0 commit comments

Comments
 (0)