get_metrics.sh: tweak script to make it more accurate

* update list of "kunit devs", this makes the external contribution
count go down by 24+
* don't count merge commits as test patches
* don't count files like mm/slub.c as test files (this made the test
contributors shoot up to >200 since 5.13)
  * change it to look for files that contain "test" or "_kunit"
* also add a "-v" flag to dump the full list of tests and authors to
make debugging easier

Current output is:
Unique contributors:	26
Number of patches:	53
Number of total tests:	29
Number of test authors:	47

Change-Id: I1ec5abe14d650b2901cafe927c87e865b931882c
Signed-off-by: Daniel Latypov <dlatypov@google.com>
diff --git a/get_metrics.sh b/get_metrics.sh
index 4213d20..70bb5b4 100755
--- a/get_metrics.sh
+++ b/get_metrics.sh
@@ -1,23 +1,18 @@
-#! /bin/bash
+#!/bin/bash
 
-unique_contributors_num=$(git --no-pager shortlog -n -s -- include/kunit lib/kunit tools/testing/kunit/ | wc -l)
+VERBOSE=
+[[ $1 == "-v" ]] && VERBOSE=y
+
+unique_contributors_num=$(git --no-pager shortlog --no-merges -n -s -- include/kunit lib/kunit tools/testing/kunit/ | wc -l)
 patches_not_from_team_num=$(git log --pretty=oneline --perl-regexp \
-  --author='^((?!Brendan Higgins|David Gow|Heidi Fahim|Felix Guo|Avinash Kondareddy).*)$' \
+  --author='^((?!Brendan Higgins|David Gow|Heidi Fahim|Felix Guo|Avinash Kondareddy|Daniel Latypov).*)$' \
   -- include/kunit lib/kunit tools/testing/kunit/ | wc -l)
 
-not_tests='lib/kunit/debugfs.c
-lib/kunit/string-stream.c
-lib/kunit/try-catch.c
-lib/kunit/assert.c
-lib/kunit/debugfs.h
-lib/kunit/test.c
-init/main.c
-mm/kasan/report.c
-Documentation/dev-tools/kunit/start.rst
-get_metrics.sh
+# Manual list of files to exclude in `all_tests`.
+not_tests='lib/kunit/test.c
 '
 
-all_tests=$(for file_name in $(grep -Hrnl -e '#include <kunit/test.h>')
+all_tests=$(for file_name in $(grep -Hrnl -e '#include <kunit/test.h>' | grep -E 'test|_kunit\.c' | grep -v '^Documentation')
 do
   if [[ ! $not_tests =~ (^|[[:space:]])"$file_name"($|[[:space:]]) ]] ; then
     printf "$file_name\n"
@@ -25,13 +20,16 @@
 done)
 
 tests_total_num=$(echo "$all_tests" | wc -l)
-test_authors=$(git --no-pager shortlog -n -s -- $all_tests)
+test_authors=$(git --no-pager shortlog --no-merges -n -s -- $all_tests)
 test_author_num=$(echo "$test_authors" | wc -l)
 test_case_num=$(find ./ -type f ! -wholename '*/Documentation/*' ! -name 'test.h' -name 'get_metrics.sh' -print0 |
   xargs -0 grep 'KUNIT_CASE' | wc -l)
 
-#printf "All tests:\t$all_tests\n"
-#printf "Test authors:\t$test_authors\n"
+
+if [[ -n $VERBOSE ]]; then
+  printf "All tests:\t$all_tests\n"
+  printf "Test authors:\t$test_authors\n"
+fi
 printf "Unique contributors:\t$unique_contributors_num\n"
 printf "Number of patches:\t$patches_not_from_team_num\n"
 printf "Number of total tests:\t$tests_total_num\n"