Skip to content

Commit 40189cb

Browse files
committed
Add optional unacceptable language ignore file
Some of our repos contain code that is pulled in from third parties such as swift-crypto that vendors boringssl. This code can contain unacceptable language. We cannot disable this currently since the only way to do this is by adding comments. To support such use-cases this PR extends the unacceptable-language script to also look for an optional `.unacceptablelanguageignore` file at the root of the repo.
1 parent 00b2aba commit 40189cb

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

.github/workflows/scripts/check-unacceptable-language.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,21 @@ fatal() { error "$@"; exit 1; }
1919

2020
test -n "${UNACCEPTABLE_WORD_LIST:-}" || fatal "UNACCEPTABLE_WORD_LIST unset"
2121

22-
log "Checking for unacceptable language..."
23-
unacceptable_language_lines=$(git grep \
24-
-i -I -w \
25-
-H -n --column \
26-
-E "${UNACCEPTABLE_WORD_LIST// /|}" | grep -v "ignore-unacceptable-language"
27-
) || true | /usr/bin/paste -s -d " " -
22+
unacceptable_language_lines=
23+
if [[ -f .unacceptablelanguageignore ]]; then
24+
log "Found for unacceptable file..."
25+
log "Checking for unacceptable language..."
26+
unacceptable_language_lines=$(tr '\n' '\0' < .unacceptablelanguageignore | xargs -0 -I% printf '":(exclude)%" '| xargs git grep -i -I -w -H -n --column -E "${UNACCEPTABLE_WORD_LIST// /|}" | grep -v "ignore-unacceptable-language") || true | /usr/bin/paste -s -d " " -
27+
else
28+
log "Checking for unacceptable language..."
29+
unacceptable_language_lines=$(git grep -i -I -w -H -n --column -E "${UNACCEPTABLE_WORD_LIST// /|}" | grep -v "ignore-unacceptable-language") || true | /usr/bin/paste -s -d " " -
30+
fi
2831

2932
if [ -n "${unacceptable_language_lines}" ]; then
3033
fatal " ❌ Found unacceptable language:
3134
${unacceptable_language_lines}
3235
"
3336
fi
3437

38+
3539
log "✅ Found no unacceptable language."

0 commit comments

Comments
 (0)