From fbd5182d2771780633987daba4ffa2bf574d4b73 Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Thu, 27 Jun 2024 12:20:48 -0700 Subject: [PATCH] Fix `build-order` calculation inside `diff-pr.sh` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I noticed this while reviewing the recent `kong` diff and seeing this odd bit: ```diff diff --git a/_bashbrew-list-build-order b/kong_2/kong.tar.gz similarity index 100% copy from _bashbrew-list-build-order copy to kong_2/kong.tar.gz ``` Knowing that `kong.tar.gz` is supposed to be an empty file, I wondered why `_bashbrew-list-build-order` was apparently empty, and discovered that it's because `.TagEntries` is only available/valid when we're actually passing _tags_ to `bashbrew`. 😅 --- diff-pr.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/diff-pr.sh b/diff-pr.sh index 031909d0a9ddd..fe6b0ec106433 100755 --- a/diff-pr.sh +++ b/diff-pr.sh @@ -345,7 +345,12 @@ _metadata-files() { "$diffDir/_bashbrew-cat-sorted.sh" "$@" 2>>temp/_bashbrew.err > temp/_bashbrew-cat || : - bashbrew cat --format "$templateLastTags" "$@" \ + # piping "bashbrew list" first so that .TagEntries is filled up (keeping "templateLastTags" simpler) + # sorting that by version number so it's ~stable + # then doing --build-order on that, which is a "stable sort" + # then redoing that list back into "templateLastTags" so we get the tags we want listed (not the tags "--uniq" chooses) + bashbrew list --uniq "$@" \ + | xargs -r bashbrew cat --format "$templateLastTags" \ | sort -V \ | xargs -r bashbrew list --uniq --build-order 2>>temp/_bashbrew.err \ | xargs -r bashbrew cat --format "$templateLastTags" 2>>temp/_bashbrew.err \ @@ -359,6 +364,9 @@ _metadata-files() { ( eval "$script" | tar -xiC tar ) copy-tar tar temp rm -rf tar + + # TODO we should *also* validate that our lists ended up non-empty 😬 + cat >&2 temp/_bashbrew.err fi if [ -n "$externalPins" ] && command -v crane &> /dev/null; then