From e6a48b78edacbbda94336bfe5c921fc91ba93764 Mon Sep 17 00:00:00 2001 From: meh Date: Fri, 21 Aug 2026 03:18:24 +0700 Subject: [PATCH] ci: let the one-rev check pass a lockfile with no git sources grep exits 1 when it matches nothing, and set -o pipefail turns that into a failed check. So the moment the last git dependency went away, the script that exists to police git dependencies started failing on the best possible lockfile, and it went red on master. The success message said "one rev per git source" either way, which would have read as a pass of a check that never ran. It now says "no git sources" when there are none. --- scripts/check-one-rev-per-git-source.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/check-one-rev-per-git-source.sh b/scripts/check-one-rev-per-git-source.sh index 913e919..12d55ae 100755 --- a/scripts/check-one-rev-per-git-source.sh +++ b/scripts/check-one-rev-per-git-source.sh @@ -29,8 +29,13 @@ set -euo pipefail lock="${1:-Cargo.lock}" # `source = "git+URL?rev=SHA#SHORTSHA"` - strip the fragment, split on `?rev=`. +# +# `|| true` on the grep because a lockfile with no git sources at all is the +# goal, not a failure, and grep exits 1 when it matches nothing. Under +# `pipefail` that failed the check on precisely the lockfile it most wants to +# see, which is what happened the day the last git dependency went away. duplicates=$( - grep -o 'source = "git+[^"]*"' "$lock" | + { grep -o 'source = "git+[^"]*"' "$lock" || true; } | sed 's/source = "git+//; s/"$//; s/#.*//' | sort -u | awk -F'\\?rev=' 'NF == 2 { count[$1]++; revs[$1] = revs[$1] "\n " $2 } @@ -46,4 +51,8 @@ if [[ -n $duplicates ]]; then exit 1 fi -echo "one rev per git source" +if grep -q 'source = "git+' "$lock"; then + echo "one rev per git source" +else + echo "no git sources" +fi