@@ -94,6 +94,35 @@ is_new_detector() {
9494 grep -qxF " $1 " " $NEW_DIRS_FILE "
9595}
9696
97+ # Step 2b — skip detectors whose diff doesn't touch regex patterns or Keywords.
98+ # Corpora results only change when the matching logic changes; verification,
99+ # redaction, or structural changes don't affect match counts.
100+ has_pattern_change () {
101+ local dir=" $1 "
102+
103+ # Fast path: regex or Keywords() signature on a changed line.
104+ git diff " $MERGE_BASE ...$HEAD_REF " -- " $dir " /* .go 2> /dev/null \
105+ | grep -qE ' ^[+-][^+-].*(regexp\.|MustCompile|Keywords)' && return 0
106+
107+ # Slow path: compare the Keywords() function body between refs to catch
108+ # changes to the return value (e.g. []string{"old"} → []string{"new"})
109+ # where the changed lines don't mention "Keywords" themselves.
110+ local file
111+ while IFS= read -r file; do
112+ [[ " $file " == * _test.go ]] && continue
113+ local head_body base_body
114+ head_body=$( git show " $HEAD_REF :$file " 2> /dev/null \
115+ | awk ' /func[[:space:]].*Keywords\(\)[[:space:]]*\[\]string/,/^[[:space:]]*\}/' \
116+ | tail -n +2)
117+ base_body=$( git show " $MERGE_BASE :$file " 2> /dev/null \
118+ | awk ' /func[[:space:]].*Keywords\(\)[[:space:]]*\[\]string/,/^[[:space:]]*\}/' \
119+ | tail -n +2)
120+ [[ " $head_body " != " $base_body " ]] && return 0
121+ done < <( git diff --name-only " $MERGE_BASE ...$HEAD_REF " -- " $dir " /* .go 2> /dev/null)
122+
123+ return 1
124+ }
125+
97126# Step 3 — for a dir, derive `<protoname>[.v<n>]`.
98127detector_id_for_dir () {
99128 local dir=" $1 "
@@ -127,6 +156,7 @@ emit_list() {
127156 local dir id
128157 for dir in " ${CHANGED_DIRS[@]:- } " ; do
129158 [[ -z " $dir " ]] && continue
159+ has_pattern_change " $dir " || continue
130160 if id=$( detector_id_for_dir " $dir " ) ; then
131161 echo " $id "
132162 else
@@ -139,6 +169,7 @@ emit_main_list() {
139169 local dir id
140170 for dir in " ${CHANGED_DIRS[@]:- } " ; do
141171 [[ -z " $dir " ]] && continue
172+ has_pattern_change " $dir " || continue
142173 # Strip `pkg/detectors/` prefix to get the import-path form, then
143174 # check against the new-detector set.
144175 local import_form=" ${dir# pkg/ detectors/ } "
@@ -155,6 +186,7 @@ emit_new_list() {
155186 local dir id
156187 for dir in " ${CHANGED_DIRS[@]:- } " ; do
157188 [[ -z " $dir " ]] && continue
189+ has_pattern_change " $dir " || continue
158190 local import_form=" ${dir# pkg/ detectors/ } "
159191 if ! is_new_detector " $import_form " ; then
160192 continue
0 commit comments