Skip to content

Commit 7558699

Browse files
committed
Fix trailing whitespace in output functions
1 parent 77dae8d commit 7558699

File tree

5 files changed

+61
-43
lines changed

5 files changed

+61
-43
lines changed

lib/output.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ANSI_BLUE='\033[1;34m'
44
ANSI_RED='\033[1;31m'
55
ANSI_YELLOW='\033[1;33m'
66
ANSI_RESET='\033[0m'
7+
MESSAGE_INDENTATION=' '
78

89
# Output a single line step message to stdout.
910
#
@@ -36,10 +37,15 @@ function output::indent() {
3637
# EOF
3738
# ```
3839
function output::notice() {
39-
local line
40+
local line indentation
4041
echo >&2
4142
while IFS= read -r line; do
42-
echo -e "${ANSI_BLUE} ! ${line}${ANSI_RESET}" >&2
43+
indentation=""
44+
if [[ -n "${line}" ]]; then
45+
indentation="${MESSAGE_INDENTATION}"
46+
fi
47+
48+
echo -e "${ANSI_BLUE} !${indentation}${line}${ANSI_RESET}" >&2
4349
done
4450
echo >&2
4551
}
@@ -55,10 +61,15 @@ function output::notice() {
5561
# EOF
5662
# ```
5763
function output::warning() {
58-
local line
64+
local line indentation
5965
echo >&2
6066
while IFS= read -r line; do
61-
echo -e "${ANSI_YELLOW} ! ${line}${ANSI_RESET}" >&2
67+
indentation=""
68+
if [[ -n "${line}" ]]; then
69+
indentation="${MESSAGE_INDENTATION}"
70+
fi
71+
72+
echo -e "${ANSI_YELLOW} !${indentation}${line}${ANSI_RESET}" >&2
6273
done
6374
echo >&2
6475
}
@@ -74,10 +85,15 @@ function output::warning() {
7485
# EOF
7586
# ```
7687
function output::error() {
77-
local line
88+
local line indentation
7889
echo >&2
7990
while IFS= read -r line; do
80-
echo -e "${ANSI_RED} ! ${line}${ANSI_RESET}" >&2
91+
indentation=""
92+
if [[ -n "${line}" ]]; then
93+
indentation="${MESSAGE_INDENTATION}"
94+
fi
95+
96+
echo -e "${ANSI_RED} !${indentation}${line}${ANSI_RESET}" >&2
8197
done
8298
echo >&2
8399
}

test/spec/misc_spec.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,26 @@
7272
remote: \\[ERROR\\]
7373
remote: \\[ERROR\\] For more information about the errors and possible solutions, please read the following articles:
7474
remote: \\[ERROR\\] \\[Help 1\\] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
75-
remote:
75+
remote:
7676
remote: ! Error: Maven build failed.
77-
remote: !
77+
remote: !
7878
remote: ! An error occurred during the Maven build process. This usually
7979
remote: ! indicates an issue with your application's dependencies, configuration,
8080
remote: ! or source code.
81-
remote: !
81+
remote: !
8282
remote: ! First, check the build output above for specific error messages
8383
remote: ! from Maven that might indicate what went wrong. Common issues include:
84-
remote: !
84+
remote: !
8585
remote: ! - Missing or incompatible dependencies in your POM
8686
remote: ! - Compilation errors in your application source code
8787
remote: ! - Test failures \\(if tests are enabled during the build\\)
8888
remote: ! - Invalid Maven configuration or settings
8989
remote: ! - Using an incompatible OpenJDK version for your project
90-
remote: !
90+
remote: !
9191
remote: ! If you're unable to determine the cause from the Maven output,
9292
remote: ! try building your application locally with the same Maven command
9393
remote: ! to reproduce and debug the issue.
94-
remote:
94+
remote:
9595
remote: ! Push rejected, failed to compile Java app.
9696
REGEX
9797
end
@@ -108,21 +108,21 @@
108108
expect(app.output).to include('[INFO] BUILD SUCCESS')
109109
expect(clean_output(app.output)).to match(Regexp.new(<<~REGEX, Regexp::MULTILINE))
110110
remote: ! Warning: Maven Wrapper script found without properties file\\.
111-
remote: !
111+
remote: !
112112
remote: ! Found mvnw script but missing \\.mvn/wrapper/maven-wrapper\\.properties\\.
113113
remote: ! The Maven Wrapper requires both files to function properly\\.
114-
remote: !
114+
remote: !
115115
remote: ! To fix this issue, run this command in your project directory
116116
remote: ! locally and commit the generated files:
117117
remote: ! \\$ mvn wrapper:wrapper
118-
remote: !
118+
remote: !
119119
remote: ! Alternatively, if you don't want to use Maven Wrapper, you can
120120
remote: ! delete the mvnw file from your project, though the usage of the
121121
remote: ! Maven Wrapper is strongly recommended\\.
122-
remote: !
122+
remote: !
123123
remote: ! IMPORTANT: This warning will become an error in a future version
124124
remote: ! of this buildpack\\. Please fix this issue as soon as possible\\.
125-
remote: !
125+
remote: !
126126
remote: ! For more information about Maven Wrapper, see:
127127
remote: ! https://maven\\.apache\\.org/tools/wrapper/
128128
remote: ! https://devcenter\\.heroku\\.com/articles/java-support#specifying-a-maven-version

test/spec/settings_xml_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@
1818
app.deploy do
1919
expect(clean_output(app.output)).to include(<<~OUTPUT)
2020
remote: ! Error: Unable to download Maven settings.xml.
21-
remote: !
21+
remote: !
2222
remote: ! An error occurred while downloading the Maven settings file from:
2323
remote: ! #{SETTINGS_XML_URL_404}
24-
remote: !
24+
remote: !
2525
remote: ! In some cases, this happens due to a temporary issue with
2626
remote: ! the network connection or server, or because the URL is
2727
remote: ! inaccessible or requires authentication.
28-
remote: !
28+
remote: !
2929
remote: ! Check that the URL in your MAVEN_SETTINGS_URL environment
3030
remote: ! variable is correct and publicly accessible. If the settings file
31-
remote: ! is not needed, you can remove the MAVEN_SETTINGS_URL environment variable
31+
remote: ! is not needed, you can remove the MAVEN_SETTINGS_URL environment variable
3232
remote: ! to use default Maven settings.
33-
remote: !
33+
remote: !
3434
remote: ! Learn more about Maven settings configuration:
3535
remote: ! https://devcenter.heroku.com/articles/using-a-custom-maven-settings-xml
36-
remote:
36+
remote:
3737
remote: ! Push rejected, failed to compile Java app.
3838
OUTPUT
3939
end
@@ -147,12 +147,12 @@
147147
app.deploy do
148148
expect(clean_output(app.output)).to match(Regexp.new(<<~REGEX, Regexp::MULTILINE))
149149
remote: ! Warning: Using existing settings\\.xml file\\.
150-
remote: !
150+
remote: !
151151
remote: ! A settings\\.xml file already exists at .*\\.m2/settings\\.xml\\.
152152
remote: ! However, the MAVEN_SETTINGS_PATH environment variable is set, which
153153
remote: ! would normally be used as the settings\\.xml configuration\\. The existing
154154
remote: ! file will be used\\.
155-
remote: !
155+
remote: !
156156
remote: ! If you intended to use the settings from MAVEN_SETTINGS_PATH instead,
157157
remote: ! remove the existing settings\\.xml file at .*\\.m2/settings\\.xml\\.
158158
REGEX
@@ -215,12 +215,12 @@
215215
app.deploy do
216216
expect(clean_output(app.output)).to match(Regexp.new(<<~REGEX, Regexp::MULTILINE))
217217
remote: ! Warning: Using existing settings\\.xml file\\.
218-
remote: !
218+
remote: !
219219
remote: ! A settings\\.xml file already exists at .*\\.m2/settings\\.xml\\.
220220
remote: ! However, a settings\\.xml file was also found in the project directory,
221221
remote: ! which would normally be used as the settings\\.xml configuration\\. The
222222
remote: ! existing file will be used\\.
223-
remote: !
223+
remote: !
224224
remote: ! If you intended to use the settings from your project directory instead,
225225
remote: ! remove the existing settings\\.xml file at .*\\.m2/settings\\.xml\\.
226226
REGEX

test/spec/spec_helper.rb

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

test/spec/versions_spec.rb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,32 @@
3737
app.deploy do
3838
expect(clean_output(app.output)).to include(<<~OUTPUT)
3939
remote: -----> Installing Maven #{UNKNOWN_MAVEN_VERSION}...
40-
remote:
40+
remote:
4141
remote: ! Error: The requested Maven version isn't available.
42-
remote: !
42+
remote: !
4343
remote: ! Your app's system.properties file specifies a Maven version
4444
remote: ! of #{UNKNOWN_MAVEN_VERSION}, however, we couldn't find that version in the
4545
remote: ! Maven repository.
46-
remote: !
46+
remote: !
4747
remote: ! Check that this Maven version has been released upstream:
4848
remote: ! https://maven.apache.org/docs/history.html
49-
remote: !
49+
remote: !
5050
remote: ! If it has, make sure that you are using the latest version
5151
remote: ! of this buildpack, and haven't pinned to an older release:
5252
remote: ! https://devcenter.heroku.com/articles/managing-buildpacks#view-your-buildpacks
5353
remote: ! https://devcenter.heroku.com/articles/managing-buildpacks#classic-buildpacks-references
54-
remote: !
54+
remote: !
5555
remote: ! We also strongly recommend using the Maven Wrapper instead of
5656
remote: ! pinning to an exact Maven version such as #{UNKNOWN_MAVEN_VERSION}.
5757
remote: ! Remove the maven.version property from your system.properties file
5858
remote: ! and set up Maven Wrapper in your project, which will automatically
5959
remote: ! download and use the correct Maven version.
60-
remote: !
60+
remote: !
6161
remote: ! Learn more about Maven Wrapper:
6262
remote: ! https://maven.apache.org/wrapper/
63-
remote: !
63+
remote: !
6464
remote: ! The default supported version is #{DEFAULT_MAVEN_VERSION}.
65-
remote:
65+
remote:
6666
remote: ! Push rejected, failed to compile Java app.
6767
OUTPUT
6868
end
@@ -93,32 +93,32 @@
9393
app.deploy do
9494
expect(clean_output(app.output)).to include(<<~OUTPUT)
9595
remote: -----> Installing Maven #{UNKNOWN_MAVEN_VERSION}...
96-
remote:
96+
remote:
9797
remote: ! Error: The requested Maven version isn't available.
98-
remote: !
98+
remote: !
9999
remote: ! Your app's system.properties file specifies a Maven version
100100
remote: ! of #{UNKNOWN_MAVEN_VERSION}, however, we couldn't find that version in the
101101
remote: ! Maven repository.
102-
remote: !
102+
remote: !
103103
remote: ! Check that this Maven version has been released upstream:
104104
remote: ! https://maven.apache.org/docs/history.html
105-
remote: !
105+
remote: !
106106
remote: ! If it has, make sure that you are using the latest version
107107
remote: ! of this buildpack, and haven't pinned to an older release:
108108
remote: ! https://devcenter.heroku.com/articles/managing-buildpacks#view-your-buildpacks
109109
remote: ! https://devcenter.heroku.com/articles/managing-buildpacks#classic-buildpacks-references
110-
remote: !
110+
remote: !
111111
remote: ! We also strongly recommend using the Maven Wrapper instead of
112112
remote: ! pinning to an exact Maven version such as #{UNKNOWN_MAVEN_VERSION}.
113113
remote: ! Remove the maven.version property from your system.properties file
114114
remote: ! and set up Maven Wrapper in your project, which will automatically
115115
remote: ! download and use the correct Maven version.
116-
remote: !
116+
remote: !
117117
remote: ! Learn more about Maven Wrapper:
118118
remote: ! https://maven.apache.org/wrapper/
119-
remote: !
119+
remote: !
120120
remote: ! The default supported version is #{DEFAULT_MAVEN_VERSION}.
121-
remote:
121+
remote:
122122
remote: ! Push rejected, failed to compile Java app.
123123
OUTPUT
124124
end

0 commit comments

Comments
 (0)