check-vendor-manifest.sh 781 B

1234567891011121314151617
  1. #!/usr/bin/env bash
  2. # Vendoring discipline, mechanized: any staged change under vendor/*/src or a
  3. # vendored bin.js must come with a vendor/README.md change in the same commit
  4. # (the manifest's local-modification log is the contract — see vendor/README.md).
  5. set -euo pipefail
  6. staged=$(git diff --cached --name-only)
  7. vendor_src_changed=$(echo "$staged" | grep -E '^vendor/[^/]+/(src/|bin\.js)' || true)
  8. manifest_changed=$(echo "$staged" | grep -x 'vendor/README.md' || true)
  9. if [[ -n "$vendor_src_changed" && -z "$manifest_changed" ]]; then
  10. echo 'vendor manifest guard: vendored SOURCE changed without updating vendor/README.md:'
  11. echo "$vendor_src_changed" | sed 's/^/ /'
  12. echo 'Log the modification in vendor/README.md ("Local modifications") and stage it.'
  13. exit 1
  14. fi