update_inclusive_language_presubmit_exempt_dirs.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. # Copyright 2021 The Chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. # Produce a list of directories that contain files with instances of
  6. # non-inclusive language (e.g. whitelist, blacklist, master, slave). Each line
  7. # is formatted: <path> <instance count across files> <distinct file count>
  8. # (separated by spaces). The counts are not recursive, so they do not sum up
  9. # values from child directories, only files directly in the listed path.
  10. #
  11. # The intended consumer of this list is the CheckInclusiveLanguage function
  12. # in ../PRESUBMIT.py. It does not perform its check on files directly under
  13. # the paths listed here.
  14. #
  15. # See https://bugs.chromium.org/p/chromium/issues/detail?id=1177609 for more
  16. # context.
  17. #
  18. # To update the list so the PRESUBMIT will use it in prod, write the output to
  19. # ./inclusive_language_presubmit_exempt_dirs in a new CL, and land it. Example:
  20. #
  21. # % infra/update_inclusive_language_presubmit_exempt_dirs.sh > \
  22. # infra/inclusive_language_presubmit_exempt_dirs.txt
  23. #
  24. # Note: This script produces the list relative to the current working dir.
  25. # To generate the list of exempted legacy directories for chromium/src for
  26. # instance, you should run this from the parent of the current directory
  27. # rather than from this directory.
  28. git grep -c -E '\b((black|white)list|master|slave)\b' | \
  29. awk -F ":" 'NF {cmd=sprintf("dirname %s",$1);cmd | getline dirname; \
  30. a[dirname] += $2; b[dirname] += 1} END {for (i in a) print i, a[i], b[i]}' \
  31. | sort