#!/bin/bash

set -e

remote="$1"
url="$2"

z40=0000000000000000000000000000000000000000

while read local_ref local_sha remote_ref remote_sha
do
  if [[ "${local_sha}" = $z40 ]]; then
    echo "Deleting stuff, nothing to do"
  else
    cargo clippy -- -D clippy::unwrap_used
    cargo clippy --all-targets -- --deny warnings
    cargo test
    cargo run -- check --non-interactive --project-path . $(fd --type f -E "tests/*")
    cargo install --path .
    (
      cd tests
      poetry run pytest -n auto
     )
  fi
done

exit 0
