test_licenses.sh 708 B

123456789101112131415161718192021
  1. #!/usr/bin/env bash
  2. # This test checks that all source files correctly have license headers
  3. INCLUDE_EXTENSIONS="h|cpp|hpp|py|c"
  4. EXCLUDE_LIST="(.*\\/(qtermwidget)\\/|.*\\/(auto_additions)\\/|ui_defaults\\.h|qgspluginmanager_texts\\.cpp|src\\/analysis\\/vector\\/mersenne-twister\\.|^[^.]*$|.*\\.(?!($INCLUDE_EXTENSIONS)$))"
  5. LICENSE_CHECK="scripts/licensecheck.pl"
  6. DIR=$(git rev-parse --show-toplevel)
  7. pushd "${DIR}" > /dev/null || exit
  8. missing=$(! { "$LICENSE_CHECK" -r -i "$EXCLUDE_LIST" src & "$LICENSE_CHECK" -r -i "$EXCLUDE_LIST" python; } | grep UNKNOWN)
  9. popd > /dev/null || exit
  10. if [[ $missing ]]; then
  11. echo " *** Found source files without valid license headers"
  12. echo "$missing"
  13. exit 1
  14. fi