check_buck_targets.sh 926 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env bash
  2. # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  3. if [[ ! -f "BUCK" ]]
  4. then
  5. echo "BUCK file is missing!"
  6. echo "Please do not remove / rename BUCK file in your commit(s)."
  7. exit 1
  8. fi
  9. TGT_DIFF=`git diff BUCK | head -n 1`
  10. if [ ! -z "$TGT_DIFF" ]
  11. then
  12. echo "BUCK file has uncommitted changes. Skip this check."
  13. exit 0
  14. fi
  15. echo Backup original BUCK file.
  16. cp BUCK BUCK.bkp
  17. ${PYTHON:-python3} buckifier/buckify_rocksdb.py
  18. if [[ ! -f "BUCK" ]]
  19. then
  20. echo "BUCK file went missing after running buckifier/buckify_rocksdb.py!"
  21. echo "Please do not remove the BUCK file."
  22. exit 1
  23. fi
  24. TGT_DIFF=`git diff BUCK | head -n 1`
  25. if [ -z "$TGT_DIFF" ]
  26. then
  27. mv BUCK.bkp BUCK
  28. exit 0
  29. else
  30. echo "Please run '${PYTHON:-python3} buckifier/buckify_rocksdb.py' to update BUCK file."
  31. echo "Do not manually update BUCK file."
  32. ${PYTHON:-python3} --version
  33. mv BUCK.bkp BUCK
  34. exit 1
  35. fi