From 0d4aa9b629d5a26f4d2af1083046bbfc422caf49 Mon Sep 17 00:00:00 2001 From: rodia Date: Fri, 5 Sep 2025 11:31:34 -0300 Subject: [PATCH] feat: Add refresh_cache --- Rakefile | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/Rakefile b/Rakefile index 1dfdec2..577a916 100644 --- a/Rakefile +++ b/Rakefile @@ -97,3 +97,46 @@ end def compose(*arg, compose: DOCKER_COMPOSE) sh "docker-compose -f #{compose} #{arg.join(' ')}" end + +def refresh_cache + # cuando se realizan cambios sobre los modelos + # que afectan las tablas es necesario limpiar el cache + # de trytond + changes = [] + + has_git_dir = File.directory?(File.join(File.dirname(__FILE__), '.git')) + try_git = `which git`.then { $? }.success? && has_git_dir + try_fossil = system('fossil status', err: :close, out: :close) + + if try_fossil + changes = %x{fossil diff}.split("\n").grep(/^[-+]/) + elsif try_git + changes = %x{git diff -- '*.xml' ':!*view*'}.split("\n").grep(/^[-+index]/) + else + warn < 0 && (tdd_cache != hash) + compose('exec', 'app.dev', 'bash -c "rm -f /tmp/*.dump"') + cache.seek(0); cache.write(hash) + end + end +end