check_copyright.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #-------------------------------------------------------------------------------------------------------
  2. # Copyright (C) Microsoft. All rights reserved.
  3. # Copyright (c) ChakraCore Project Contributors. All rights reserved.
  4. # Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  5. #-------------------------------------------------------------------------------------------------------
  6. # Need to make sure that the reference to origin/master is available.
  7. # We know that HEAD is checked out so that the tests on that source can be run.
  8. # configure the sh environment to run scripts from the bin dir in case that's missing
  9. ls &> /dev/null # checking for ls script on the path
  10. if [ $? -ne 0 ]; then
  11. PATH=/bin:/usr/bin:$PATH
  12. fi
  13. ERRFILE=check_copyright.sh.err
  14. ERRFILETEMP=$ERRFILE.0
  15. rm -f $ERRFILE
  16. rm -f $ERRFILETEMP
  17. echo "Check Copyright > Begin Checking..."
  18. git diff --name-only `git merge-base origin/master HEAD` HEAD |
  19. grep -v -E '\.git.*' |
  20. grep -v -E '\.xml$' |
  21. grep -v -E '\.xsd$' |
  22. grep -v -E '\.yml$' |
  23. grep -v -E '\.props$' |
  24. grep -v -E '\.md$' |
  25. grep -v -E '\.txt$' |
  26. grep -v -E '\.baseline$' |
  27. grep -v -E '\.sln$' |
  28. grep -v -E '\.wasm$' |
  29. grep -v -E '\.vcxproj$' |
  30. grep -v -E '\.filters$' |
  31. grep -v -E '\.targets$' |
  32. grep -v -E '\.nuspec$' |
  33. grep -v -E '\.mustache$' |
  34. grep -v -E '\.pack-version$' |
  35. grep -v -E '\.def$' |
  36. grep -v -E '\.inc$' |
  37. grep -v -E '\.cmake$' |
  38. grep -v -E '\.json$' |
  39. grep -v -E '\.man$' |
  40. grep -v -E '\.testconfig$' |
  41. grep -v -E '\.editorconfig$' |
  42. grep -v -E '\.proj$' |
  43. grep -v -E '\.png$' |
  44. grep -v -E 'packages.config$' |
  45. grep -v -E 'lib/wabt/.*' |
  46. grep -v -E 'test/WasmSpec.*$' |
  47. grep -v -E 'test/UnitTestFramework/yargs.js$' |
  48. grep -v -E 'test/benchmarks/.*\.js$' |
  49. grep -v -E 'test/benchmarks/.*\.js_c$' |
  50. grep -v -E 'bin/External/.*$' |
  51. grep -v -E 'bin/NativeTests/Scripts/splay.js$' |
  52. grep -v -E 'libChakraCoreLib.version|ch.version' |
  53. grep -v -E 'lib/Backend/CRC.h' |
  54. xargs -I % sh -c "echo 'Check Copyright > Checking %'; python tools/StyleChecks/check_copyright.py % > $ERRFILETEMP || cat $ERRFILETEMP >> $ERRFILE"
  55. rm -f $ERRFILETEMP
  56. if [ -e $ERRFILE ]; then # if error file exists then there were errors
  57. >&2 echo "--------------" # leading >&2 means echo to stderr
  58. >&2 echo "--- ERRORS ---"
  59. cat $ERRFILE 1>&2 # send output to stderr so it can be redirected as error if desired
  60. >&2 echo "--------------"
  61. exit 1 # tell the caller there was an error (so the CI task will fail)
  62. else
  63. echo "--- NO PROBLEMS DETECTED ---"
  64. fi