66set -e
77if [ -n " $DEBUG " ]; then
88 set -x
9+ begingroup () {
10+ echo " ::group::$1 "
11+ }
12+ endgroup () {
13+ echo ' ::endgroup::'
14+ }
15+ else
16+ begingroup () {
17+ :
18+ }
19+ endgroup () {
20+ :
21+ }
922fi
1023
1124now () {
@@ -86,12 +99,14 @@ xargs_zero() {
8699 args=" $* " " $spellchecker /xargs_zero"
87100 fi
88101}
102+ begingroup ' Spell check'
89103(git ' ls-files' -z 2> /dev/null) | \
90104 " $spellchecker /exclude.pl" | \
91105 xargs_zero " $word_splitter " | \
92106 " $word_splitter " | \
93107 perl -p -n -e ' s/ \(.*//' > " $run_output "
94108 word_splitter_status=" ${PIPESTATUS[2]} ${PIPESTATUS[3]} "
109+ endgroup
95110 if [ " $word_splitter_status " != ' 0 0' ]; then
96111 echo " $word_splitter failed ($word_splitter_status )"
97112 exit 2
@@ -202,6 +217,8 @@ bullet_words() {
202217 fi
203218 if [ -s " $run_warnings .raw" ]; then
204219 (
220+ endgroup
221+ begingroup ' Misspellings'
205222 echo " ::add-matcher::.git/reporter.json"
206223 cat " $run_warnings .raw"
207224 echo " ::remove-matcher owner=jsoref-spelling::"
@@ -246,6 +263,7 @@ comment() {
246263}
247264
248265if [ ! -e " $whitelist_path " ]; then
266+ begingroup ' No whitelist'
249267 title=" No preexisting $whitelist_path file"
250268 instructions=$(
251269 echo ' cat > ' " $whitelist_path " ' <<EOF=EOF'
@@ -254,22 +272,30 @@ if [ ! -e "$whitelist_path" ]; then
254272 to_publish_whitelist
255273 )
256274 spelling_info " $title " " $( bullet_words " $( cat " $run_output " ) " ) " " $instructions "
275+ endgroup
257276 quit 2
258277fi
278+
279+ begingroup ' Compare whitelist with new output'
259280sorted_whitelist=" $temp /$( basename $whitelist_path ) "
260281(sort -u -f " $whitelist_path " | grep . || true) > " $sorted_whitelist "
261282whitelist_path=" $sorted_whitelist "
262283
263284diff_output=$( diff -U0 " $whitelist_path " " $run_output " | grep -v " $spellchecker " || true)
285+ endgroup
264286
265287if [ -z " $diff_output " ]; then
288+ begingroup ' No misspellings'
266289 title=" No new words with misspellings found"
267290 spelling_info " $title " " There are currently $( wc -l $whitelist_path | sed -e ' s/ .*//' ) whitelisted items." " "
291+ endgroup
268292 quit 0
269293fi
270294
295+ begingroup ' New output'
271296new_output=$( diff -i -U0 " $whitelist_path " " $run_output " | grep -v " $spellchecker " | \
272297 perl -n -w -e ' next unless /^\+/; next if /^\+{3} /; s/^.//; print;' )
298+ endgroup
273299
274300make_instructions () {
275301 patch_remove=$( echo " $diff_output " | perl -ne ' next unless s/^-([^-])/$1/; print' )
@@ -293,16 +319,20 @@ make_instructions() {
293319}
294320
295321if [ -z " $new_output " ]; then
322+ begingroup ' Fewer misspellings'
296323 title=' There are now fewer misspellings than before'
297324 instructions=$(
298325 make_instructions
299326 )
300327 spelling_info " $title " " $( bullet_words " $( new_words " $diff_output " ) " ) " " $instructions "
328+ endgroup
301329 quit
302330fi
331+ begingroup ' New misspellings'
303332title=' New misspellings found, please review'
304333instructions=$(
305334 make_instructions
306335)
307336 spelling_warning " $title " " $( bullet_words " $new_output " ) " " $instructions "
337+ endgroup
308338quit 1
0 commit comments