verify-sparse-checkout-non-cone-mode.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/sh
  2. # Verify .git folder
  3. if [ ! -d "./sparse-checkout-non-cone-mode/.git" ]; then
  4. echo "Expected ./sparse-checkout-non-cone-mode/.git folder to exist"
  5. exit 1
  6. fi
  7. # Verify sparse-checkout (non-cone-mode)
  8. cd sparse-checkout-non-cone-mode
  9. ENABLED=$(git config --local --get-all core.sparseCheckout)
  10. if [ "$?" != "0" ]; then
  11. echo "Failed to verify that sparse-checkout is enabled"
  12. exit 1
  13. fi
  14. # Check that sparse-checkout is enabled
  15. if [ "$ENABLED" != "true" ]; then
  16. echo "Expected sparse-checkout to be enabled (is: $ENABLED)"
  17. exit 1
  18. fi
  19. SPARSE_CHECKOUT_FILE=$(git rev-parse --git-path info/sparse-checkout)
  20. if [ "$?" != "0" ]; then
  21. echo "Failed to validate sparse-checkout"
  22. exit 1
  23. fi
  24. # Check that sparse-checkout list is not empty
  25. if [ ! -f "$SPARSE_CHECKOUT_FILE" ]; then
  26. echo "Expected sparse-checkout file to exist"
  27. exit 1
  28. fi
  29. # Check that all folders from sparse-checkout exists
  30. for pattern in $(cat "$SPARSE_CHECKOUT_FILE")
  31. do
  32. if [ ! -d "${pattern#/}" ]; then
  33. echo "Expected directory '${pattern#/}' to exist"
  34. exit 1
  35. fi
  36. done
  37. # Verify that the root directory is not checked out
  38. if [ -f README.md ]; then
  39. echo "Expected top-level files not to exist"
  40. exit 1
  41. fi