From a7d974e670673b331313098b09ebddd627aab8e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 18 Feb 2020 17:08:23 +0100 Subject: [PATCH] ci: Prohibit template strings in translatable files Sadly, xgettext's dealing with template strings is abysimal, so we had to stop using them in files with translatable strings. Make sure we don't accidentally sneak in template strings again(*) and enforce that rule in a CI job. (*) easy "mistake", considering how much nicer they are than String.prototype.format() https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1016 --- .gitlab-ci.yml | 7 +++++++ .gitlab-ci/check-template-strings.sh | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 .gitlab-ci/check-template-strings.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3b4d23ab9..c7f925cc0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -53,6 +53,13 @@ potfile_check: - ./.gitlab-ci/check-potfiles.sh <<: *only_default +no_template_check: + image: registry.gitlab.gnome.org/gnome/gnome-shell/extension-ci:v1 + stage: review + script: + - ./.gitlab-ci/check-template-strings.sh + <<: *only_default + build: image: registry.gitlab.gnome.org/gnome/mutter/master:v3 stage: build diff --git a/.gitlab-ci/check-template-strings.sh b/.gitlab-ci/check-template-strings.sh new file mode 100755 index 000000000..efa8afc1f --- /dev/null +++ b/.gitlab-ci/check-template-strings.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# find files from POTFILES.in that use js template strings +baddies=$(grep -l '${' $(grep ^js po/POTFILES.in)) + +if [ ${#baddies} -eq 0 ]; then + exit 0 +fi + +cat >&2 <&2 +done +echo >&2 + +exit 1