#!/bin/sh

# jq filter to check that the wit-manifest contins a given commit (\1) and package (\2)
filter='.[]|select(.commit == "\1")|select(.name == "\2")'

# only check that all submodules have a corresponding wit package
# the wit-manifest.json may have packages that are not submoduled
# e.g. api-chisel3-sifive
git submodule status \
| sed -r "s/\-([a-zA-Z0-9]+)\s([a-zA-Z0-9\-]+)/$filter/g" \
| xargs -d '\n' -I % sh -c "jq -e '%' wit-manifest.json"
