From 22b5d6cb7f9f5036f10a851c6769a2f90e41697e Mon Sep 17 00:00:00 2001 From: "Jovany Leandro G.C bit4bit@riseup.net" Date: Tue, 1 Aug 2023 18:47:43 -0500 Subject: [PATCH] chore: se limpia cache de trytond fixes #18 --- .gitignore | 2 ++ Rakefile | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/.gitignore b/.gitignore index fa62fc5..afc9d4c 100644 --- a/.gitignore +++ b/.gitignore @@ -217,3 +217,5 @@ tags pyvenv.cfg .venv pip-selfcheck.json + +.tdd_cache \ No newline at end of file diff --git a/Rakefile b/Rakefile index 21bdc2a..2612e52 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,5 @@ require 'yaml' +require 'digest' WOODPECKER_YML='.woodpecker.yml' DOCKER_COMPOSE='compose.test.yml' @@ -24,6 +25,24 @@ end desc 'iterar' task :tdd do + # cuando se realizan cambios sobre los modelos + # que afectan las tablas es necesario limpiar el cache + # de trytond + if `which git`.then { $? }.success? + changes = %x{git diff}.split("\n").grep(/^[-+]/) + num = changes.grep(/fields/).length + hash = Digest::MD5.hexdigest(changes.flatten.join('')) + + File.open('.tdd_cache', 'r+') do |cache| + tdd_cache = cache.read() + + if num > 0 && (tdd_cache != hash) + compose('exec', 'app.dev', 'rm -f /tmp/*.dump') + cache.seek(0); cache.write(hash) + end + end + end + compose('exec', 'app.dev', 'python3 -m unittest') end