From 4f55a4a4609da49ec0bdd4c9e7db1b05e58c6060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Wed, 19 Jan 2022 21:57:09 +0100 Subject: [PATCH] scripts: Add check for resources.gresource.xml --- scripts/checks.sh | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/scripts/checks.sh b/scripts/checks.sh index 9f904c6e..5dd7a68a 100755 --- a/scripts/checks.sh +++ b/scripts/checks.sh @@ -388,6 +388,41 @@ check_potfiles() { fi } +# Check if files in data/resources/resources.gresource.xml are sorted alphabetically. +check_resources() { + echo -e "$Checking data/resources/resources.gresource.xml…" + + local ret=0 + + # Get files. + regex="(.*)" + while read -r line; do + if [[ $line =~ $regex ]]; then + files+=("${BASH_REMATCH[1]}") + fi + done < data/resources/resources.gresource.xml + + # Check sorted alphabetically + to_sort=("${files[@]}") + sort + for i in ${!files[@]}; do + if [[ "${files[$i]}" != "${to_sort[$i]}" ]]; then + echo -e "$error Found file '${files[$i]#src/}' before '${to_sort[$i]#src/}' in resources.gresource.xml" + ret=1 + break + fi + done + + if [[ ret -eq 1 ]]; then + echo "" + echo -e " Checking data/resources/resources.gresource.xml result: $fail" + echo "Please fix the above issues" + exit 1 + else + echo -e " Checking data/resources/resources.gresource.xml result: $ok" + fi +} + # Check arguments while [[ "$1" ]]; do case $1 in -f | --force-install ) @@ -412,4 +447,7 @@ run_rustfmt echo "" run_typos echo "" -check_potfiles \ No newline at end of file +check_potfiles +echo "" +check_resources +echo ""