Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ANSI escape code wrapping of deprecation messages #477

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions builder-classic-22/end-of-life-buildpack/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

set -euo pipefail

ANSI_RED="\033[1;31m"
ANSI_RESET="\033[0m"

function display_error() {
local ansi_red="\033[1;31m"
local ansi_reset="\033[0m"
echo -e "\n${ansi_red}${1}${ansi_reset}\n" >&2
echo >&2
# We have to ANSI wrap each line separately to prevent breakage if line prefixes are added
# later (such as when the builder is untrusted, or when Git adds the "remote:" prefix).
while IFS= read -r line; do
echo -e "${ANSI_RED}${line}${ANSI_RESET}" >&2
done <<< "${1}"
echo >&2
}

read -r -d '' EOL_MESSAGE <<'EOF' || true
display_error "$(cat <<'EOF'
#######################################################################

WARNING: This builder image (heroku/builder-classic:22) is deprecated,
Expand All @@ -31,6 +38,6 @@ documentation for how to adjust the builder image used for your build.

#######################################################################
EOF
)"

display_error "${EOL_MESSAGE}"
exit 0
17 changes: 12 additions & 5 deletions buildpacks-20/end-of-life-buildpack/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

set -euo pipefail

ANSI_RED="\033[1;31m"
ANSI_RESET="\033[0m"

function display_error() {
local ansi_red="\033[1;31m"
local ansi_reset="\033[0m"
echo -e "\n${ansi_red}${1}${ansi_reset}\n" >&2
echo >&2
# We have to ANSI wrap each line separately to prevent breakage if line prefixes are added
# later (such as when the builder is untrusted, or when Git adds the "remote:" prefix).
while IFS= read -r line; do
echo -e "${ANSI_RED}${line}${ANSI_RESET}" >&2
done <<< "${1}"
echo >&2
}

read -r -d '' EOL_MESSAGE <<'EOF' || true
display_error "$(cat <<'EOF'
#######################################################################

WARNING: This builder image (heroku/buildpacks:20) is deprecated,
Expand All @@ -31,6 +38,6 @@ documentation for how to adjust the builder image used for your build.

#######################################################################
EOF
)"

display_error "${EOL_MESSAGE}"
exit 0