#!/usr/bin/env bash
set -uo pipefail

cd "$(git rev-parse --show-toplevel)" || exit 0

bash scripts/rules.sh || exit 1

nothing=0000000000000000000000000000000000000000
status=0
while read -r ref mine _ _; do
  [ -n "${mine:-}" ] || continue
  [ "$mine" != "$nothing" ] || continue

  # a tag carries no subjects of its own
  case ${ref:-} in
    refs/tags/v*) continue ;;
  esac

  bash scripts/commits.sh "$mine" --not --remotes || status=1
done

exit $status
