Skip to content

Commit

Permalink
Fix build-order calculation inside diff-pr.sh
Browse files Browse the repository at this point in the history
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`. 😅
  • Loading branch information
tianon committed Jun 27, 2024
1 parent 1105601 commit fbd5182
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion diff-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
Expand Down

0 comments on commit fbd5182

Please sign in to comment.