Skip to content

Commit 2d04b1f

Browse files
committed
Improve lint_localized_strings_format logs parsing
These changes had already been discussed in wordpress-mobile/WordPress-iOS#19553 and applied in the test PR used for it, but I forgot to cherry pick them back on the original one. Once I copied the script over to this project, I did it from the branch without the improvements.
1 parent 510da63 commit 2d04b1f

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

bin/lint_localized_strings_format

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,19 @@ if [[ $EXIT_CODE -ne 0 ]]; then
2929
# Strings generation finished with errors, extract the errors in an easy-to-find section
3030
echo "+++ :x: Strings Generation Failed"
3131
ERRORS=errors.txt
32-
echo "Found errors when trying to run \`genstrings\` to generate the \`.strings\` files from \`{NS,App}LocalizedStrings\` calls:" | tee $ERRORS
33-
echo '' >> $ERRORS
32+
printf "Found errors when trying to run \`genstrings\` to generate the \`.strings\` files from \`{NS,App}LocalizedStrings\` calls:\n\n" | tee $ERRORS
3433
# Print the errors inline.
3534
#
3635
# Notice the second `sed` call that removes the ANSI escape sequences that
37-
# Fastlane uses to color the output.
38-
grep -e "\[.*\].*genstrings:" $LOGS \
39-
| sed -e 's/\[.*\].*genstrings: error: /- /' \
36+
# Fastlane uses to color the output. We need to do this at this point to
37+
# account for Fastlane printing the errors multiple times (inline and in the
38+
# end of the lane summary) but with different escape sequences. Without it,
39+
# we would get multiple hits for the same error.
40+
#
41+
# See discussion at
42+
# https://github.com/wordpress-mobile/WordPress-iOS/pull/19553#discussion_r1017743950
43+
cat $LOGS \
44+
| sed -ne 's/\[.*\].*genstrings: error: /- /p' \
4045
| sed -e $'s/\x1b\[[0-9;]*m//g' \
4146
| sort \
4247
| uniq \

0 commit comments

Comments
 (0)