Skip to content

Commit d89fd51

Browse files
committed
List a std crate once when it is both detected and known to be there
1 parent 062c7ef commit d89fd51

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎.github/scripts/sbom.sh‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,13 @@ rust_components() {
5757
case $crates in *miniz_oxide-*) crates=$(printf '%s\n' "$crates" adler2-auto) ;; esac
5858
[ "$(tc rustc)" = "$rustc_version" ] || { echo "$bin: built with rustc $(tc rustc), but $rustc_version is installed" >&2; exit 1; }
5959
local list=() crate name found lock_version
60+
local -A seen=()
61+
# detected versions sort before "auto", so a crate found in the binary wins
6062
for crate in $(printf '%s\n' "$crates" | sed '/^$/d' | sort -u); do
6163
name=${crate%-*}
6264
found=${crate##*-}
65+
[ -z "${seen[$name]:-}" ] || continue
66+
seen[$name]=1
6367
lock_version=$(awk -v n="$name" '$0 == "name = \"" n "\"" { getline; gsub(/version = |"/, ""); print; exit }' "$std_lock")
6468
[ -n "$lock_version" ] || { echo "$bin: $name is not one of std's dependencies" >&2; exit 1; }
6569
[ "$found" = auto ] || [ "$found" = "$lock_version" ] || { echo "$bin: $name $found, std uses $lock_version" >&2; exit 1; }

0 commit comments

Comments
 (0)