check_tabs.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_tabs.sh.err
  13. rm -f $ERRFILE
  14. # git diff --name-only `git merge-base origin/master HEAD` HEAD | xargs grep -P -l "\t" > /dev/nul
  15. git diff --name-only `git merge-base origin/master HEAD` HEAD |
  16. xargs grep -P -l "\t" |
  17. grep -v -E '^pal/' |
  18. grep -v -E '\Makefile$' |
  19. grep -v -E '\.sln$' |
  20. grep -v -E '\.js$' |
  21. grep -v -E '\.baseline$' |
  22. grep -v -E '\.wasm$' |
  23. grep -v -E '\.wast$' |
  24. grep -v -E '^lib/wabt' |
  25. grep -v -E 'bin/External/.*$' |
  26. xargs -I % sh -c 'echo --- IN FILE % ---; git blame HEAD -- % | grep -P "(\t|--- IN FILE)"' > check_tabs.sh.err
  27. if [ -s $ERRFILE ]; then # if file exists and is non-empty then there were errors
  28. >&2 echo "--------------" # leading >&2 means echo to stderr
  29. >&2 echo "--- ERRORS ---"
  30. >&2 echo ""
  31. cat $ERRFILE 1>&2 # send output to stderr so it can be redirected as error if desired
  32. exit 1
  33. else
  34. echo "--- NO PROBLEMS DETECTED ---"
  35. fi