check_tabs.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #-------------------------------------------------------------------------------------------------------
  2. # Copyright (C) Microsoft. All rights reserved.
  3. # Copyright (c) 2021 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_tabs.sh.err
  14. rm -f $ERRFILE
  15. # git diff --name-only `git merge-base origin/master HEAD` HEAD | xargs grep -P -l "\t" > /dev/nul
  16. git diff --name-only `git merge-base origin/master HEAD` HEAD |
  17. xargs grep -P -l "\t" |
  18. grep -v -E '^pal/' |
  19. grep -v -E '\Makefile$' |
  20. grep -v -E '\Makefile.sample$' |
  21. grep -v -E '\.sln$' |
  22. grep -v -E '\.js$' |
  23. grep -v -E '\.baseline$' |
  24. grep -v -E '\.wasm$' |
  25. grep -v -E '\.wast$' |
  26. grep -v -E '\.png$' |
  27. grep -v -E '^lib/wabt' |
  28. grep -v -E 'bin/External/.*$' |
  29. xargs -I % sh -c 'echo --- IN FILE % ---; git blame HEAD -- % | grep -P "(\t|--- IN FILE)"' > check_tabs.sh.err
  30. if [ -s $ERRFILE ]; then # if file exists and is non-empty then there were errors
  31. >&2 echo "--------------" # leading >&2 means echo to stderr
  32. >&2 echo "--- ERRORS ---"
  33. >&2 echo ""
  34. cat $ERRFILE 1>&2 # tell the caller there was an error (so the CI task will fail)
  35. exit 1
  36. else
  37. echo "--- NO PROBLEMS DETECTED ---"
  38. fi