check-sources.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env bash
  2. # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  3. #
  4. # Check for some simple mistakes that should prevent commit or push
  5. BAD=""
  6. git grep -n 'namespace rocksdb' -- '*.[ch]*'
  7. if [ "$?" != "1" ]; then
  8. echo "^^^^^ Do not hardcode namespace rocksdb. Use ROCKSDB_NAMESPACE"
  9. BAD=1
  10. fi
  11. git grep -n -i 'nocommit' -- ':!build_tools/check-sources.sh'
  12. if [ "$?" != "1" ]; then
  13. echo "^^^^^ Code was not intended to be committed"
  14. BAD=1
  15. fi
  16. git grep -n 'include <rocksdb/' -- ':!build_tools/check-sources.sh'
  17. if [ "$?" != "1" ]; then
  18. echo '^^^^^ Use double-quotes as in #include "rocksdb/something.h"'
  19. BAD=1
  20. fi
  21. git grep -n 'include "include/rocksdb/' -- ':!build_tools/check-sources.sh'
  22. if [ "$?" != "1" ]; then
  23. echo '^^^^^ Use #include "rocksdb/something.h" instead of #include "include/rocksdb/something.h"'
  24. BAD=1
  25. fi
  26. git grep -n 'using namespace' -- ':!build_tools' ':!docs' \
  27. ':!third-party/folly/folly/lang/Align.h' \
  28. ':!third-party/gtest-1.8.1/fused-src/gtest/gtest.h'
  29. if [ "$?" != "1" ]; then
  30. echo '^^^^ Do not use "using namespace"'
  31. BAD=1
  32. fi
  33. git grep -n -P "[\x80-\xFF]" -- ':!docs' ':!*.md'
  34. if [ "$?" != "1" ]; then
  35. echo '^^^^ Use only ASCII characters in source files'
  36. BAD=1
  37. fi
  38. if [ "$BAD" ]; then
  39. exit 1
  40. fi