Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions scripts/check-one-rev-per-git-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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
Loading