#!/bin/bash
# List packages that are UNRELEASED and also not pending.
set -e

git grep -l UNRELEASED-FIXME-AUTOGENERATED-DEBCARGO -- src/*/debian/changelog | cut -d/ -f2 | \
"$(dirname "$0")/filter-pending.sh" | \
grep " 0$" | \
cut '-d ' -f1 | \
while read pkg; do
	crate="$(sed -nre "s/.*Package (.*) .* from crates.io.*/\1/gp" src/$pkg/debian/changelog | head -n1)"
	pkgbase="${crate//_/-}"
	if [ "$pkg" = "$pkgbase" ]; then
		echo "$crate"
	else
		echo "$crate" "${pkg#$pkgbase-}"
	fi
done
