Skip to content

Commit 715232d

Browse files
authored
Fix trailing whitespace in output functions (#180)
1 parent 5c39b3a commit 715232d

File tree

4 files changed

+59
-41
lines changed

4 files changed

+59
-41
lines changed

lib/output.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ ANSI_BLUE='\033[1;34m'
88
ANSI_RED='\033[1;31m'
99
ANSI_YELLOW='\033[1;33m'
1010
ANSI_RESET='\033[0m'
11+
MESSAGE_INDENTATION=' '
1112

1213
# Output a single line step message to stdout.
1314
#
@@ -40,10 +41,15 @@ function output::indent() {
4041
# EOF
4142
# ```
4243
function output::notice() {
43-
local line
44+
local line indentation
4445
echo >&2
4546
while IFS= read -r line; do
46-
echo -e "${ANSI_BLUE} ! ${line}${ANSI_RESET}" >&2
47+
indentation=""
48+
if [[ -n "${line}" ]]; then
49+
indentation="${MESSAGE_INDENTATION}"
50+
fi
51+
52+
echo -e "${ANSI_BLUE} !${indentation}${line}${ANSI_RESET}" >&2
4753
done
4854
echo >&2
4955
}
@@ -59,10 +65,15 @@ function output::notice() {
5965
# EOF
6066
# ```
6167
function output::warning() {
62-
local line
68+
local line indentation
6369
echo >&2
6470
while IFS= read -r line; do
65-
echo -e "${ANSI_YELLOW} ! ${line}${ANSI_RESET}" >&2
71+
indentation=""
72+
if [[ -n "${line}" ]]; then
73+
indentation="${MESSAGE_INDENTATION}"
74+
fi
75+
76+
echo -e "${ANSI_YELLOW} !${indentation}${line}${ANSI_RESET}" >&2
6677
done
6778
echo >&2
6879
}
@@ -78,10 +89,15 @@ function output::warning() {
7889
# EOF
7990
# ```
8091
function output::error() {
81-
local line
92+
local line indentation
8293
echo >&2
8394
while IFS= read -r line; do
84-
echo -e "${ANSI_RED} ! ${line}${ANSI_RESET}" >&2
95+
indentation=""
96+
if [[ -n "${line}" ]]; then
97+
indentation="${MESSAGE_INDENTATION}"
98+
fi
99+
100+
echo -e "${ANSI_RED} !${indentation}${line}${ANSI_RESET}" >&2
85101
done
86102
echo >&2
87103
}

test/spec/detection_spec.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,28 @@
99
expect(clean_output(app.output)).to include(<<~OUTPUT)
1010
remote: ! Error: Your app is configured to use the Gradle buildpack,
1111
remote: ! but we couldn't find any supported Gradle project files.
12-
remote: !
12+
remote: !
1313
remote: ! The Gradle buildpack requires at least one of the following files
1414
remote: ! in the root directory of your source code:
15-
remote: !
15+
remote: !
1616
remote: ! Supported Gradle files: gradlew, build.gradle, build.gradle.kts, settings.gradle, settings.gradle.kts
17-
remote: !
17+
remote: !
1818
remote: ! IMPORTANT: If your project uses a different build tool:
1919
remote: ! - For Maven projects, use the heroku/java buildpack instead
2020
remote: ! - For sbt projects, use the heroku/scala buildpack instead
21-
remote: !
21+
remote: !
2222
remote: ! Currently the root directory of your app contains:
23-
remote: !
23+
remote: !
2424
remote: ! README.md
25-
remote: !
25+
remote: !
2626
remote: ! If your app already has Gradle files, check that they:
27-
remote: !
27+
remote: !
2828
remote: ! 1. Are in the top level directory (not a subdirectory).
2929
remote: ! 2. Have the correct spelling (the filenames are case-sensitive).
3030
remote: ! 3. Aren't listed in '.gitignore' or '.slugignore'.
3131
remote: ! 4. Have been added to the Git repository using 'git add --all'
3232
remote: ! and then committed using 'git commit'.
33-
remote: !
33+
remote: !
3434
remote: ! For help with using Gradle on Heroku, see:
3535
remote: ! https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku
3636
OUTPUT

test/spec/misc_spec.rb

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@
1414
app.deploy do
1515
expect(clean_output(app.output)).to include(<<~OUTPUT)
1616
remote: ! Error: Gradle Wrapper is missing.
17-
remote: !
17+
remote: !
1818
remote: ! The Gradle Wrapper (gradlew) is required to build your application on Heroku.
1919
remote: ! This ensures that your application builds with the same version of Gradle
2020
remote: ! that you use during development. Projects are required to include
2121
remote: ! their own Wrapper for reliable, reproducible builds.
22-
remote: !
22+
remote: !
2323
remote: ! Note: The buildpack used to provide a default Gradle Wrapper (using Gradle 2.0) for
2424
remote: ! applications that didn't include their own wrapper. That workaround was deprecated
2525
remote: ! in 2014 and has now been removed.
26-
remote: !
26+
remote: !
2727
remote: ! To fix this issue, run this command in your project directory
2828
remote: ! locally and commit the generated files:
2929
remote: ! $ gradle wrapper
30-
remote: !
30+
remote: !
3131
remote: ! If you don't have Gradle installed locally, you can install it first:
3232
remote: ! https://gradle.org/install/
33-
remote: !
33+
remote: !
3434
remote: ! For more information about Gradle Wrapper, see:
3535
remote: ! https://docs.gradle.org/current/userguide/gradle_wrapper.html
3636
remote: ! https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku
@@ -49,27 +49,27 @@
4949
app.deploy do
5050
expect(clean_output(app.output)).to include(<<~OUTPUT)
5151
remote: ! Error: Failed to start Gradle daemon.
52-
remote: !
52+
remote: !
5353
remote: ! An error occurred while starting the Gradle daemon. This usually
5454
remote: ! indicates an issue with the Gradle wrapper, build configuration,
5555
remote: ! or system resources.
56-
remote: !
56+
remote: !
5757
remote: ! Check the output above for specific error messages from Gradle.
5858
remote: ! Common causes include:
59-
remote: !
59+
remote: !
6060
remote: ! - Corrupted or missing Gradle wrapper files
6161
remote: ! - Invalid Gradle configuration in build.gradle(.kts) or settings.gradle(.kts)
6262
remote: ! - Network connectivity issues downloading Gradle dependencies
6363
remote: ! - Incompatible Gradle version with the current Java runtime
64-
remote: !
64+
remote: !
6565
remote: ! To resolve this issue:
6666
remote: ! 1. Verify your Gradle wrapper works locally: ./gradlew --version
6767
remote: ! 2. Check your build.gradle(.kts) and settings.gradle(.kts) for syntax errors
6868
remote: ! 3. Ensure you're using a supported Gradle version
69-
remote: !
69+
remote: !
7070
remote: ! If this appears to be a temporary network or download issue,
7171
remote: ! try deploying again as it may resolve itself.
72-
remote: !
72+
remote: !
7373
remote: ! For more information, see:
7474
remote: ! https://docs.gradle.org/current/userguide/troubleshooting.html
7575
OUTPUT
@@ -95,25 +95,25 @@
9595
app.deploy do
9696
expect(clean_output(app.output)).to include(<<~OUTPUT)
9797
remote: ! Error: Gradle build failed.
98-
remote: !
98+
remote: !
9999
remote: ! An error occurred during the Gradle build process. This usually
100100
remote: ! indicates an issue with your application's dependencies, configuration,
101101
remote: ! or source code.
102-
remote: !
102+
remote: !
103103
remote: ! First, check the build output above for specific error messages
104104
remote: ! from Gradle that might indicate what went wrong. Common issues include:
105-
remote: !
105+
remote: !
106106
remote: ! - Missing or incompatible dependencies in your build.gradle(.kts)
107107
remote: ! - Compilation errors in your application source code
108108
remote: ! - Test failures (if tests are enabled during the build)
109109
remote: ! - Invalid Gradle configuration or settings
110110
remote: ! - Using an incompatible OpenJDK version for your project
111-
remote: !
111+
remote: !
112112
remote: ! To troubleshoot this issue:
113113
remote: ! 1. Try building your application locally with the same Gradle command
114114
remote: ! 2. Check that your gradlew script works locally: ./gradlew build
115115
remote: ! 3. Verify your Java version is compatible with your project
116-
remote: !
116+
remote: !
117117
remote: ! If the error persists, check the documentation:
118118
remote: ! https://docs.gradle.org/current/userguide/troubleshooting.html
119119
remote: ! https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku
@@ -129,24 +129,24 @@
129129
app.deploy do
130130
expect(clean_output(app.output)).to include(<<~OUTPUT)
131131
remote: ! Error: Gradle task 'pleasefail' not found.
132-
remote: !
132+
remote: !
133133
remote: ! The specified Gradle task 'pleasefail' does not exist in your project.
134134
remote: ! This can happen when:
135-
remote: !
135+
remote: !
136136
remote: ! - The task name is misspelled
137137
remote: ! - The task is defined in a plugin that hasn't been applied
138138
remote: ! - The task is only available in certain project configurations
139139
remote: ! - You're trying to run a task that doesn't exist in this project
140-
remote: !
140+
remote: !
141141
remote: ! To see all available tasks in your project, run locally:
142142
remote: ! $ ./gradlew tasks
143-
remote: !
143+
remote: !
144144
remote: ! To see all tasks including those from plugins, run:
145145
remote: ! $ ./gradlew tasks --all
146-
remote: !
146+
remote: !
147147
remote: ! If you're setting GRADLE_TASK as an environment variable, make sure
148148
remote: ! it contains a valid task name for your project.
149-
remote: !
149+
remote: !
150150
remote: ! For more information about Gradle tasks, see:
151151
remote: ! https://docs.gradle.org/current/userguide/more_about_tasks.html
152152
OUTPUT
@@ -158,20 +158,20 @@
158158
app.deploy do
159159
expect(clean_output(app.output)).to include(<<~OUTPUT)
160160
remote: ! Warning: Unsupported Gradle version detected.
161-
remote: !
161+
remote: !
162162
remote: ! You are using Gradle 7.6.3, which is end-of-life and no longer
163163
remote: ! receives security updates or bug fixes.
164-
remote: !
164+
remote: !
165165
remote: ! Please upgrade to Gradle 9 (current) for active support, or at minimum
166166
remote: ! Gradle 8 for security fixes only.
167-
remote: !
167+
remote: !
168168
remote: ! This buildpack will attempt to build your application, but compatibility
169169
remote: ! with unsupported Gradle versions is not guaranteed and may break in future
170170
remote: ! buildpack releases. We strongly recommend upgrading.
171-
remote: !
171+
remote: !
172172
remote: ! For more information:
173173
remote: ! - https://docs.gradle.org/current/userguide/feature_lifecycle.html#eol_support
174-
remote: !
174+
remote: !
175175
remote: ! Upgrade guides:
176176
remote: ! - https://docs.gradle.org/current/userguide/upgrading_version_7.html
177177
remote: ! - https://docs.gradle.org/current/userguide/upgrading_major_version_9.html

test/spec/spec_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@ def clean_output(output)
5151
.gsub(/ {8}(?=\R)/, '')
5252
# Remove ANSI colour codes used in buildpack output (e.g. error messages).
5353
.gsub(/\e\[[0-9;]+m/, '')
54+
# Remove trailing space from empty "remote: " lines added by Heroku
55+
.gsub(/^remote: $/, 'remote:')
5456
end

0 commit comments

Comments
 (0)