From 713ac1f2380d1b3d73cedca4800c472c6377daef Mon Sep 17 00:00:00 2001 From: Pascal Bourgault Date: Thu, 19 Sep 2024 13:50:04 -0400 Subject: [PATCH 1/3] add debug output to lint --- Makefile | 2 ++ tox.ini | 1 + 2 files changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 4acee60c..1a0451da 100644 --- a/Makefile +++ b/Makefile @@ -118,8 +118,10 @@ translate: ## Compile the translation catalogs. pybabel compile -f -D xscen -d src/xscen/data/ checkfrench: ## Error if the catalog could be update or if the compilation is older than the catalog. + stat src/xscen/data/fr/LC_MESSAGES/xscen.po rm -f .check_messages.pot pybabel extract -o .check_messages.pot --omit-header --input-dirs=src/xscen/ --no-location pybabel update -l fr -D xscen -i .check_messages.pot -d src/xscen/data/ --omit-header --check + stat src/xscen/data/fr/LC_MESSAGES/xscen.po rm -f .check_messages.pot if [ src/xscen/data/fr/LC_MESSAGES/xscen.mo -ot src/xscen/data/fr/LC_MESSAGES/xscen.po ]; then echo "Compilation is older than translations. Please compile with 'make translate'."; exit 1; fi diff --git a/tox.ini b/tox.ini index 5ed966da..ad5b8a7e 100644 --- a/tox.ini +++ b/tox.ini @@ -34,6 +34,7 @@ deps = commands_pre = pip list commands = + stat src/xscen/data/fr/LC_MESSAGES/xscen.po make lint make checkfrench allowlist_externals = From e58c473ffe89f4e775fdbec11f1621baa3a62870 Mon Sep 17 00:00:00 2001 From: Pascal Bourgault Date: Thu, 19 Sep 2024 13:53:14 -0400 Subject: [PATCH 2/3] allow stat for debugging purposes --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index ad5b8a7e..18118f1b 100644 --- a/tox.ini +++ b/tox.ini @@ -39,6 +39,7 @@ commands = make checkfrench allowlist_externals = make + stat [testenv:docs{,-esmpy}] description = Run Build of xscen Documentation From f5157c4fec596d542ec5ac2bfe0069faa6ba9a0c Mon Sep 17 00:00:00 2001 From: Pascal Bourgault Date: Thu, 19 Sep 2024 14:24:43 -0400 Subject: [PATCH 3/3] Git-based checkfrench --- Makefile | 7 ++++--- tox.ini | 2 -- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 1a0451da..1f42c520 100644 --- a/Makefile +++ b/Makefile @@ -117,11 +117,12 @@ findfrench: ## Extract phrases and update the French translation catalog (this translate: ## Compile the translation catalogs. pybabel compile -f -D xscen -d src/xscen/data/ +MO_LAST_COMMIT = $(shell git log -n 1 --pretty=format:%H -- src/xscen/data/fr/LC_MESSAGES/xscen.mo) +PO_LAST_COMMIT = $(shell git log -n 1 --pretty=format:%H -- src/xscen/data/fr/LC_MESSAGES/xscen.po) checkfrench: ## Error if the catalog could be update or if the compilation is older than the catalog. - stat src/xscen/data/fr/LC_MESSAGES/xscen.po rm -f .check_messages.pot pybabel extract -o .check_messages.pot --omit-header --input-dirs=src/xscen/ --no-location pybabel update -l fr -D xscen -i .check_messages.pot -d src/xscen/data/ --omit-header --check - stat src/xscen/data/fr/LC_MESSAGES/xscen.po rm -f .check_messages.pot - if [ src/xscen/data/fr/LC_MESSAGES/xscen.mo -ot src/xscen/data/fr/LC_MESSAGES/xscen.po ]; then echo "Compilation is older than translations. Please compile with 'make translate'."; exit 1; fi + # Last commit that touched the PO file must be an ancestor of the last that touched the MO + if git merge-base --is-ancestor $(PO_LAST_COMMIT) $(MO_LAST_COMMIT); then echo "ok"; else echo "Compilation is older than translations. Please compile with 'make translate'."; exit 1; fi diff --git a/tox.ini b/tox.ini index 18118f1b..5ed966da 100644 --- a/tox.ini +++ b/tox.ini @@ -34,12 +34,10 @@ deps = commands_pre = pip list commands = - stat src/xscen/data/fr/LC_MESSAGES/xscen.po make lint make checkfrench allowlist_externals = make - stat [testenv:docs{,-esmpy}] description = Run Build of xscen Documentation