copyright.awk 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. #
  10. # copyright.awk — checks file for missing copyright header.
  11. function err(s)
  12. {
  13. print "lint: \033[31merror:\033[0m copyright: " s > "/dev/stderr"
  14. }
  15. function done()
  16. {
  17. if (!copyright) {
  18. err(FILENAME " is missing copyright header")
  19. exit 1
  20. } else if (copyright !~ /Copyright Materialize, Inc\. and contributors\./) {
  21. err(FILENAME " has malformatted copyright header")
  22. print "hint: line " copyright_line " does not include the exact text \"Copyright Materialize, Inc. and contributors.\""
  23. exit 1
  24. }
  25. exit 0
  26. }
  27. /^#![ \t\n]*\// { next }
  28. /^(\/\/|#|--|\s+"#|;)?.*Copyright/ { copyright=$0; copyright_line=NR }
  29. /^[ \t\n]*$/ { next }
  30. # In case of ipynb files, continue into the JSON
  31. /[{}"\[\]]/ { next }
  32. !/^(<!--|<\?xml|\/\/|#|--|;)/ { done() }