From 5b8c6acbd61239eb07476bcf9e767ee2cfec2921 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 20 Jan 2021 11:21:22 +0100 Subject: [PATCH] Layout::Base: git_commit_reload_resources config parameter MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Ermöglicht das Ausschalten von git commit Resourcesversionierung das bisher immer an war. --- SL/Layout/Base.pm | 22 ++++++++++++++-------- config/kivitendo.conf.default | 5 +++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/SL/Layout/Base.pm b/SL/Layout/Base.pm index 813db7315..aa7881250 100644 --- a/SL/Layout/Base.pm +++ b/SL/Layout/Base.pm @@ -44,21 +44,27 @@ sub get { } sub init_auto_reload_resources_param { - return sprintf('?rand=%d-%d-%d', Time::HiRes::gettimeofday(), int(rand 1000000000000)) if $::lx_office_conf{debug}->{auto_reload_resources}; + if ($::lx_office_conf{debug}->{auto_reload_resources}) { + return sprintf('?rand=%d-%d-%d', Time::HiRes::gettimeofday(), int(rand 1000000000000)); + } + + if ($::lx_office_conf{debug}{git_commit_reload_resources}) { + my $git_dir = SL::System::Process::exe_dir() . '/.git'; - my $git_dir = SL::System::Process::exe_dir() . '/.git'; + return '' unless -d $git_dir; - return '' unless -d $git_dir; + my $content = eval { scalar(read_file($git_dir . '/HEAD')) }; - my $content = eval { scalar(read_file($git_dir . '/HEAD')) }; + return '' unless ($content // '') =~ m{\Aref: ([^\r\n]+)}; - return '' unless ($content // '') =~ m{\Aref: ([^\r\n]+)}; + $content = eval { scalar(read_file($git_dir . '/' . $1)) }; - $content = eval { scalar(read_file($git_dir . '/' . $1)) }; + return '' unless ($content // '') =~ m{\A([0-9a-fA-F]+)}; - return '' unless ($content // '') =~ m{\A([0-9a-fA-F]+)}; + return '?rand=' . $1; + } - return '?rand=' . $1; + return ''; } ########################################## diff --git a/config/kivitendo.conf.default b/config/kivitendo.conf.default index de9366ed4..07ae59d56 100644 --- a/config/kivitendo.conf.default +++ b/config/kivitendo.conf.default @@ -374,6 +374,11 @@ keep_installation_unlocked = 0 # the web browser to always reload the resources. auto_reload_resources = 0 +# Alternative to auto_reload_resources. If the installation dir is under git +# version control, this will use the HEAD commit sha1 as the random GET +# parameter, so that resources are reloaded if the installed version charnges. +git_commit_reload_recources = 0 + # If set to 1 each exception will include a full stack backtrace. backtrace_on_die = 0 -- 2.20.1