Skip to content

Commit 57c2521

Browse files
CCM-16537 Fixing paths for precommits
1 parent d33c3a7 commit 57c2521

2 files changed

Lines changed: 50 additions & 15 deletions

File tree

.github/actions/check-english-usage/check-english-usage.sh

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ function main() {
3131
check=${check:-working-tree-changes}
3232
case $check in
3333
"all")
34-
filter="git ls-files"
34+
filter="git ls-files -z"
3535
;;
3636
"staged-changes")
37-
filter="git diff --diff-filter=ACMRT --name-only --cached"
37+
filter="git diff --diff-filter=ACMRT --name-only --cached -z"
3838
;;
3939
"working-tree-changes")
40-
filter="git diff --diff-filter=ACMRT --name-only"
40+
filter="git diff --diff-filter=ACMRT --name-only -z"
4141
;;
4242
"branch")
43-
filter="git diff --diff-filter=ACMRT --name-only ${BRANCH_NAME:-origin/main}"
43+
filter="git diff --diff-filter=ACMRT --name-only -z ${BRANCH_NAME:-origin/main}"
4444
;;
4545
*)
4646
echo "Unrecognised check mode: $check" >&2 && exit 1
@@ -59,10 +59,17 @@ function main() {
5959
# filter=[git command to filter the files to check]
6060
function run-vale-natively() {
6161

62-
# shellcheck disable=SC2046
62+
local files=()
63+
while IFS= read -r -d '' file; do
64+
files+=("$file")
65+
done < <($filter)
66+
67+
# If no files found, exit successfully
68+
[[ ${#files[@]} -eq 0 ]] && return 0
69+
6370
vale \
6471
--config "$PWD/scripts/config/vale/vale.ini" \
65-
$($filter)
72+
"${files[@]}"
6673
}
6774

6875
# Run Vale in a Docker container.
@@ -75,17 +82,26 @@ function run-vale-in-docker() {
7582

7683
# shellcheck disable=SC2155
7784
local image=$(name=jdkato/vale docker-get-image-version-and-pull)
85+
86+
local files=()
87+
while IFS= read -r -d '' file; do
88+
files+=("$file")
89+
done < <($filter)
90+
7891
# We use /dev/null here to stop `vale` from complaining that it's
7992
# not been called correctly if the $filter happens to return an
8093
# empty list. As long as there's a filename, even if it's one that
8194
# will be ignored, `vale` is happy.
82-
# shellcheck disable=SC2046,SC2086
95+
if [[ ${#files[@]} -eq 0 ]]; then
96+
files=(/dev/null)
97+
fi
98+
8399
docker run --rm --platform linux/amd64 \
84100
--volume "$PWD:/workdir" \
85101
--workdir /workdir \
86102
"$image" \
87103
--config /workdir/scripts/config/vale/vale.ini \
88-
$($filter) /dev/null
104+
"${files[@]}"
89105
}
90106

91107
# ==============================================================================

.github/actions/check-file-format/check-file-format.sh

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ function main() {
5050
check=${check:-working-tree-changes}
5151
case $check in
5252
"all")
53-
filter="git ls-files"
53+
filter="git ls-files -z"
5454
;;
5555
"staged-changes")
56-
filter="git diff --diff-filter=ACMRT --name-only --cached"
56+
filter="git diff --diff-filter=ACMRT --name-only --cached -z"
5757
;;
5858
"working-tree-changes")
59-
filter="git diff --diff-filter=ACMRT --name-only"
59+
filter="git diff --diff-filter=ACMRT --name-only -z"
6060
;;
6161
"branch")
62-
filter="git diff --diff-filter=ACMRT --name-only ${BRANCH_NAME:-origin/main}"
62+
filter="git diff --diff-filter=ACMRT --name-only -z ${BRANCH_NAME:-origin/main}"
6363
;;
6464
*)
6565
echo "Unrecognised check mode: $check" >&2 && exit 1
@@ -79,9 +79,17 @@ function main() {
7979
# filter=[git command to filter the files to check]
8080
function run-editorconfig-natively() {
8181

82-
# shellcheck disable=SC2046,SC2086
82+
local files=()
83+
while IFS= read -r -d '' file; do
84+
files+=("$file")
85+
done < <($filter)
86+
87+
# If no files found, exit successfully
88+
[[ ${#files[@]} -eq 0 ]] && return 0
89+
90+
# shellcheck disable=SC2086
8391
editorconfig \
84-
--exclude '.git/' $dry_run_opt $($filter)
92+
--exclude '.git/' $dry_run_opt "${files[@]}"
8593
}
8694

8795
# Run editorconfig in a Docker container.
@@ -95,13 +103,24 @@ function run-editorconfig-in-docker() {
95103

96104
# shellcheck disable=SC2155
97105
local image=$(name=mstruebing/editorconfig-checker docker-get-image-version-and-pull)
106+
107+
local files=()
108+
while IFS= read -r -d '' file; do
109+
files+=("$file")
110+
done < <($filter)
111+
98112
# We use /dev/null here as a backstop in case there are no files in the state
99113
# we choose. If the filter comes back empty, adding `/dev/null` onto it has
100114
# the effect of preventing `ec` from treating "no files" as "all the files".
115+
if [[ ${#files[@]} -eq 0 ]]; then
116+
files=(/dev/null)
117+
fi
118+
119+
# shellcheck disable=SC2086
101120
docker run --rm --platform linux/amd64 \
102121
--volume "$PWD":/check \
103122
"$image" \
104-
sh -c "ec --exclude '.git/' $dry_run_opt \$($filter) /dev/null"
123+
ec --exclude '.git/' $dry_run_opt "${files[@]}"
105124
}
106125

107126
# ==============================================================================

0 commit comments

Comments
 (0)