crates-lock-check.sh anchors on `[/:]daniel/gitdan-crates(.git)?/?` and matches case-insensitively, so a trailing-slash or differently-cased second commit is counted and a look-alike owner (notdaniel/) is not. crates-access.sh unsets DEPLOY_KEY once the key file is written, so git, ssh and timeout no longer inherit it. README says three actions, not two. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MfBCVNDv3y5gm2djeZSAk4
32 lines
1.5 KiB
Bash
Executable File
32 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Fails when a Cargo.lock lists more than one commit of the gitdan-crates
|
|
# git source: two commits mean two copies of every shared type.
|
|
#
|
|
# crates-lock-check.sh <path-to-Cargo.lock>
|
|
#
|
|
# Several packages from the one source share a commit, so what counts is
|
|
# distinct commits, not entries. The query string (`?branch=main`, `?rev=...`)
|
|
# is ignored, and so is the URL's spelling (scheme, port, `.git`, a trailing
|
|
# slash, case): two copies of the repo are two copies whichever way they were
|
|
# named. A look-alike owner or repo (`notdaniel/`, `gitdan-crates-extra`) is not
|
|
# this source. No entry passes.
|
|
set -euo pipefail
|
|
|
|
[ $# -eq 1 ] || { echo "::error::crates-lock-check: expected <path-to-Cargo.lock>" >&2; exit 1; }
|
|
lock="$1"
|
|
[ -f "$lock" ] || {
|
|
echo "::error::gitdan-crates-access: lockfile '$lock' not found; set the action's 'lockfile' input to its path, or to an empty string to skip the check" >&2
|
|
exit 1
|
|
}
|
|
|
|
# source = "git+<url>[?query]#<sha>"
|
|
shas=$(sed -nE 's#^source = "git\+[^"?\#]*[/:]daniel/gitdan-crates(\.git)?/?(\?[^"\#]*)?\#([^"]*)"$#\3#Ip' "$lock" | sort -u)
|
|
count=$(grep -c . <<<"$shas" || true)
|
|
|
|
if [ "$count" -gt 1 ]; then
|
|
echo "::error::$lock locks $count different commits of gitdan-crates; every consumer must resolve one, or shared types are duplicated. Run: cargo update -p <crate> --precise <sha>, or cargo update, to unify them:" >&2
|
|
while read -r s; do echo " $s" >&2; done <<<"$shas"
|
|
exit 1
|
|
fi
|
|
echo "gitdan-crates lock check: ${count} commit(s) of gitdan-crates in $lock"
|