#!/usr/bin/env bash
# patch_deps.sh
# Replaces any pinned sciforge version in this crate's Cargo.toml with "*".
# Safe to re-run on every publication.

set -euo pipefail

TOML="$(cd "$(dirname "$0")" && pwd)/Cargo.toml"

if [[ ! -f "$TOML" ]]; then
    echo "Error: $TOML not found" >&2
    exit 1
fi

if grep -qE '^sciforge\s*=\s*"[^*]' "$TOML"; then
    sed -i 's/^sciforge\s*=\s*"[^"]*"/sciforge = "*"/' "$TOML"
    echo "Patched: $TOML"
else
    echo "Already ok: $TOML"
fi
