Slightly improved "diff-pr" output, especially around build-order
This should help avoid "empty cat" output we saw recently when something failed to fetch but was otherwise valid.
The current implementation is trying to do two things with one output:
1. normalized `bashbrew cat` diff
2. visualize `--build-order` changes
This change splits those into two separate things because combining them ends up making the diff harder to read than it should be ("changed tags + changed commit" leading to a full reordering of the diff because build-order also changed).
This commit is contained in:
parent
990cef4a9e
commit
9f6ee11257
|
|
@ -5,8 +5,7 @@ set -Eeuo pipefail
|
||||||
|
|
||||||
images="$(
|
images="$(
|
||||||
bashbrew list --repos --uniq "$@" \
|
bashbrew list --repos --uniq "$@" \
|
||||||
| sort -uV \
|
| sort -uV
|
||||||
| xargs -r bashbrew list --repos --uniq --build-order
|
|
||||||
)"
|
)"
|
||||||
set -- $images
|
set -- $images
|
||||||
|
|
||||||
|
|
@ -34,7 +33,6 @@ for img; do
|
||||||
|
|
||||||
bashbrew list --uniq "$img" \
|
bashbrew list --uniq "$img" \
|
||||||
| sort -V \
|
| sort -V \
|
||||||
| xargs -r bashbrew list --uniq --build-order \
|
|
||||||
| xargs -r bashbrew cat --format '
|
| xargs -r bashbrew cat --format '
|
||||||
{{- range $e := .TagEntries -}}
|
{{- range $e := .TagEntries -}}
|
||||||
{{- printf "\n%s\n" ($e.ClearDefaults $.Manifest.Global) -}}
|
{{- printf "\n%s\n" ($e.ClearDefaults $.Manifest.Global) -}}
|
||||||
|
|
|
||||||
48
diff-pr.sh
48
diff-pr.sh
|
|
@ -249,6 +249,35 @@ copy-tar() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# a "bashbrew cat" template that gives us the last / "least specific" tags for the arguments
|
||||||
|
# (in other words, this is "bashbrew list --uniq" but last instead of first)
|
||||||
|
templateLastTags='
|
||||||
|
{{- range .TagEntries -}}
|
||||||
|
{{- $.RepoName -}}
|
||||||
|
{{- ":" -}}
|
||||||
|
{{- .Tags | last -}}
|
||||||
|
{{- "\n" -}}
|
||||||
|
{{- end -}}
|
||||||
|
'
|
||||||
|
|
||||||
|
_metadata-files() {
|
||||||
|
bashbrew list "$@" 2>>temp/_bashbrew.err | sort -uV > temp/_bashbrew-list || :
|
||||||
|
|
||||||
|
"$diffDir/_bashbrew-cat-sorted.sh" "$@" 2>>temp/_bashbrew.err > temp/_bashbrew-cat || :
|
||||||
|
|
||||||
|
bashbrew list --uniq "$@" \
|
||||||
|
| sort -V \
|
||||||
|
| xargs -r bashbrew list --uniq --build-order 2>>temp/_bashbrew.err \
|
||||||
|
| xargs -r bashbrew cat --format "$templateLastTags" 2>>temp/_bashbrew.err \
|
||||||
|
> temp/_bashbrew-list-build-order || :
|
||||||
|
|
||||||
|
script="$(bashbrew cat --format "$template" "$@")"
|
||||||
|
mkdir tar
|
||||||
|
( eval "$script" | tar -xiC tar )
|
||||||
|
copy-tar tar temp
|
||||||
|
rm -rf tar
|
||||||
|
}
|
||||||
|
|
||||||
mkdir temp
|
mkdir temp
|
||||||
git -C temp init --quiet
|
git -C temp init --quiet
|
||||||
git -C temp config user.name 'Bogus'
|
git -C temp config user.name 'Bogus'
|
||||||
|
|
@ -257,15 +286,7 @@ git -C temp config user.email 'bogus@bogus'
|
||||||
# handle "new-image" PRs gracefully
|
# handle "new-image" PRs gracefully
|
||||||
for img; do touch "$BASHBREW_LIBRARY/$img"; [ -s "$BASHBREW_LIBRARY/$img" ] || echo 'Maintainers: New Image! :D (@docker-library-bot)' > "$BASHBREW_LIBRARY/$img"; done
|
for img; do touch "$BASHBREW_LIBRARY/$img"; [ -s "$BASHBREW_LIBRARY/$img" ] || echo 'Maintainers: New Image! :D (@docker-library-bot)' > "$BASHBREW_LIBRARY/$img"; done
|
||||||
|
|
||||||
bashbrew list "$@" 2>>temp/_bashbrew.err | sort -uV > temp/_bashbrew-list || :
|
_metadata-files "$@"
|
||||||
"$diffDir/_bashbrew-cat-sorted.sh" "$@" 2>>temp/_bashbrew.err > temp/_bashbrew-cat || :
|
|
||||||
for image; do
|
|
||||||
script="$(bashbrew cat --format "$template" "$image")"
|
|
||||||
mkdir tar
|
|
||||||
( eval "$script" | tar -xiC tar )
|
|
||||||
copy-tar tar temp
|
|
||||||
rm -rf tar
|
|
||||||
done
|
|
||||||
git -C temp add . || :
|
git -C temp add . || :
|
||||||
git -C temp commit --quiet --allow-empty -m 'initial' || :
|
git -C temp commit --quiet --allow-empty -m 'initial' || :
|
||||||
|
|
||||||
|
|
@ -276,13 +297,8 @@ git -C oi checkout --quiet pull
|
||||||
for img; do touch "$BASHBREW_LIBRARY/$img"; [ -s "$BASHBREW_LIBRARY/$img" ] || echo 'Maintainers: Deleted Image D: (@docker-library-bot)' > "$BASHBREW_LIBRARY/$img"; done
|
for img; do touch "$BASHBREW_LIBRARY/$img"; [ -s "$BASHBREW_LIBRARY/$img" ] || echo 'Maintainers: Deleted Image D: (@docker-library-bot)' > "$BASHBREW_LIBRARY/$img"; done
|
||||||
|
|
||||||
git -C temp rm --quiet -rf . || :
|
git -C temp rm --quiet -rf . || :
|
||||||
bashbrew list "$@" 2>>temp/_bashbrew.err | sort -uV > temp/_bashbrew-list || :
|
|
||||||
"$diffDir/_bashbrew-cat-sorted.sh" "$@" 2>>temp/_bashbrew.err > temp/_bashbrew-cat || :
|
_metadata-files "$@"
|
||||||
script="$(bashbrew cat --format "$template" "$@")"
|
|
||||||
mkdir tar
|
|
||||||
( eval "$script" | tar -xiC tar )
|
|
||||||
copy-tar tar temp
|
|
||||||
rm -rf tar
|
|
||||||
git -C temp add .
|
git -C temp add .
|
||||||
|
|
||||||
git -C temp diff \
|
git -C temp diff \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue