#!/usr/bin/env bash

set -e

cd "$(dirname "$0")/.."

echo "==> Detecting breaking changes"

TEST_PATHS=(
	tests/api_resources
	tests/test_client.py
	tests/test_response.py
	tests/test_legacy_response.py
)

for PATHSPEC in "${TEST_PATHS[@]}"; do
    # Try to check out previous versions of the test files
    # with the current SDK.
    git checkout "$1" -- "${PATHSPEC}" 2>/dev/null || true
done

# Instead of running the tests, use the linter to check if an
# older test is no longer compatible with the latest SDK.
PYRIGHT_PROJECT=scripts/pyrightconfig.breaking-changes.json ./scripts/lint
