check_copyright.sh 2.4 KB

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