summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEmīls <emils@mullvad.net>2020-02-18 17:25:17 +0000
committerEmīls <emils@mullvad.net>2020-02-21 16:11:26 +0000
commit70f902ae1f2f6ce2893727fc6942b2ce316d112e (patch)
tree664e8c6e0dc22fcd910ba2e3637f6ba372483603
parenta558bbbed062059dc778d78c4f179945deb5ef41 (diff)
downloadmullvadvpn-70f902ae1f2f6ce2893727fc6942b2ce316d112e.tar.xz
mullvadvpn-70f902ae1f2f6ce2893727fc6942b2ce316d112e.zip
Add script to format Android XML files
-rw-r--r--ci/ci-android-xml.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/ci/ci-android-xml.sh b/ci/ci-android-xml.sh
new file mode 100644
index 0000000000..6ebf27672f
--- /dev/null
+++ b/ci/ci-android-xml.sh
@@ -0,0 +1,31 @@
+# CI/Developer script to format
+# Relies on Tidy - https://github.com/htacg/tidy-html5
+
+
+# Autoformats Android XML files
+function tidy-up-android-xml {
+
+ tidy -xml \
+ -m \
+ -i \
+ --quiet yes \
+ --indent-attributes yes \
+ --indent-spaces 4 \
+ --literal-attributes yes \
+ android/src/main/res/*/*.xml
+ # FIXME - when tidy learns to not leave whitespace around, remove the line below - https://github.com/htacg/tidy-html5/issues/864
+ find android/src/main/res/ -name '*.xml' -exec sed -i -e 's/[ \t]*$//' '{}' ';'
+}
+
+# Autoformats Android XML files and returns 0 if no files were actually changed, or 1 if files were changed
+function tidy-verify-xml {
+ tidy-up-android-xml
+ if (( $(git diff android/src/main/res/ | wc -l) > 0 )); then
+ echo "android/src/main/res contains that were changed, XML is not formatted properly"
+ git diff android/src/main/res/
+ return 1;
+ else
+ echo "Android XML files are correctly formatted"
+ return 0;
+ fi
+}