check_copyright.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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/master 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 '\.vcxproj$' |
  26. grep -v -E '\.filters$' |
  27. grep -v -E '\.targets$' |
  28. grep -v -E '\.nuspec$' |
  29. grep -v -E '\.def$' |
  30. grep -v -E '\.inc$' |
  31. grep -v -E 'test/benchmarks/.*\.js$' |
  32. xargs -I % sh -c "echo 'Check Copyright > Checking %'; python jenkins/check_copyright.py % > $ERRFILETEMP || cat $ERRFILETEMP >> $ERRFILE"
  33. if [ -e $ERRFILE ]; then # if error file exists then there were errors
  34. >&2 echo "--------------" # leading >&2 means echo to stderr
  35. >&2 echo "--- ERRORS ---"
  36. cat $ERRFILE 1>&2 # send output to stderr so it can be redirected as error if desired
  37. >&2 echo "--------------"
  38. exit 1 # tell the caller there was an error (so Jenkins will fail the CI task)
  39. else
  40. echo "--- NO PROBLEMS DETECTED ---"
  41. fi