-
-
Notifications
You must be signed in to change notification settings - Fork 744
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
scripts/deploy.sh: add handmade linter for translation-related json files to check for tabs and odd spaces #2064
Changes from 8 commits
0a47c96
a482829
c2c968a
4508722
5c69a9b
9dd095b
3bfcbc0
201e9b9
664ff73
ac46806
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,7 @@ docs_links() | |
md="README.md" | ||
ver_md="$(grep -c "${ver_git}" "${md}")" | ||
ret=0 | ||
if [ "${ver_md}" -ne 0 ]; then | ||
if [ "${ver_md}" -eq 0 ]; then | ||
ret=1 | ||
echo "Please, update mention & links in ${md} inside Builds section for release builds with version ${ver_git}." | ||
fi; | ||
|
@@ -110,14 +110,36 @@ build_langs() | |
mk="../source/Makefile" | ||
cd Translations/ || exit 1 | ||
langs="$(echo "$(find ./*.json | sed -ne 's,^\./translation_,,; s,\.json$,,; /[A-Z]/p' ; sed -ne 's/^ALL_LANGUAGES=//p;' "${mk}")" | sed 's, ,\n,g; s,\r,,g' | sort | uniq -u)" | ||
ret=0 | ||
if [ -n "${langs}" ]; then | ||
ret=1 | ||
echo "It seems there is mismatch between supported languages and enabled builds." | ||
echo "Please, check files in Translations/ and ALL_LANGUAGES variable in source/Makefile for:" | ||
echo "${langs}" | ||
return 1 | ||
fi; | ||
return "${ret}" | ||
cd .. | ||
|
||
echo -ne "\n" | ||
grep -nH $'\11' Translations/translation*.json | ||
ret="${?}" | ||
if [ "${ret}" -eq 0 ]; then | ||
echo -ne "\t^^^^\t^^^^\n" | ||
echo "Please, remove any tabs as indention from json file(s) in Translations/ directory (see the exact files & lines in the list above)." | ||
echo "Use spaces only to indent in the future, please." | ||
echo -ne "\n" | ||
return 1 | ||
fi; | ||
|
||
grep -nH -e "^ [^ ]" -e "^ [^ ]" -e "^ [^ ]" -e "^ [^ ]" -e "^ [^ ]" -e "^ [^ ]" Translations/translation*.json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe less efficient computational wise, but at least we don't need to second guess we counted the white spaces in the grep patterns
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or variant of your grep command
edit: more compact version of previous grep alternative
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Thanks for help! I will add it as soon as possible. I was thinking to implement this in similar way, but for some reason I thought that just leaving spaces will be more easy to understand in the future, but I really like your suggestion. UPD: Done. I checked briefly on macOS with |
||
ret="${?}" | ||
if [ "${ret}" -eq 0 ]; then | ||
echo -ne "\t^^^^\t^^^^\n" | ||
echo "Please, remove any odd amount of extra spaces as indention from json file(s) in Translations/ directory (see the exact files & lines in the list above)." | ||
echo "Use even amount of spaces to indent in the future, please (two actual spaces per one indent, not tab)." | ||
echo -ne "\n" | ||
return 1 | ||
fi; | ||
|
||
return 0 | ||
} | ||
|
||
# Helper function to check code style using clang-format & grep/sed custom parsers: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the right way, and it was wrong, but it didn't trigger any errors, because at this point local directory was
Translations/
(because I forgot to addcd ..
, which is now on the line119120
below).UPD: also added a couple of checks hopefully to avoid this in the future.