File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,9 +20,20 @@ emdash=$'\xE2\x80\x94'
2020endash=$' \xE2\x80\x93 '
2121pattern=" ${emdash} |${endash} "
2222
23+ # Path prefixes excluded from the check. These contain captured upstream
24+ # content where emdash/endash come from the provider.
25+ exclude_prefixes=(
26+ " aibridge/fixtures/"
27+ )
28+
2329scan_all_files () {
30+ local pathspecs=()
31+ local prefix
32+ for prefix in " ${exclude_prefixes[@]} " ; do
33+ pathspecs+=(" :(exclude)${prefix} **" )
34+ done
2435 local output
25- output=$( git ls-files -z | xargs -0 grep -IEn " $pattern " 2> /dev/null || true)
36+ output=$( git ls-files -z -- " ${pathspecs[@]} " | xargs -0 grep -IEn " $pattern " 2> /dev/null || true)
2637 if [[ -n " $output " ]]; then
2738 echo " $output "
2839 found=1
7283 # Parse the diff to check only added lines for emdash/endash.
7384 current_file=" "
7485 current_line=0
86+ file_excluded=0
7587 while IFS= read -r diff_line; do
7688 if [[ " $diff_line " =~ ^\+\+\+\ b/(.* ) ]]; then
7789 current_file=" ${BASH_REMATCH[1]} "
90+ file_excluded=0
91+ for prefix in " ${exclude_prefixes[@]} " ; do
92+ if [[ " $current_file " == " $prefix " * ]]; then
93+ file_excluded=1
94+ break
95+ fi
96+ done
7897 fi
7998 # Anchored to hunk header structure to avoid matching
8099 # digits from trailing function context.
83102 continue
84103 fi
85104 if [[ " $diff_line " =~ ^\+ ]] && [[ ! " $diff_line " =~ ^\+\+\+\ [ab/] ]]; then
86- if echo " $diff_line " | grep -Eq " $pattern " ; then
105+ if [[ " $file_excluded " -eq 0 ]] && echo " $diff_line " | grep -Eq " $pattern " ; then
87106 echo " ${current_file} :${current_line} :${diff_line: 1} "
88107 found=1
89108 fi
You can’t perform that action at this time.
0 commit comments