From 56e4b3b843996281066732fa3412159305c963eb Mon Sep 17 00:00:00 2001 From: David Cook Date: Fri, 16 Jun 2023 09:18:54 +1000 Subject: [PATCH] Load git version once at initialisation Co-authored-by: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> --- app/views/spree/admin/overview/_version.html.haml | 2 +- config/application.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/spree/admin/overview/_version.html.haml b/app/views/spree/admin/overview/_version.html.haml index 729d0a3fe8..d9f5076ddc 100644 --- a/app/views/spree/admin/overview/_version.html.haml +++ b/app/views/spree/admin/overview/_version.html.haml @@ -1,3 +1,3 @@ %a{href:"https://github.com/openfoodfoundation/openfoodnetwork/releases", target: "_blank", title: t('.view_all_releases')} =# Show the latest tag. If there are commits since the tag, show number of commits and an identifier. If the working tree is dirty, show 'modified'. - = `git describe --tags --dirty=-modified` + = Rails.application.config.x.git_version diff --git a/config/application.rb b/config/application.rb index c3cb2db1c5..bb13b4dd50 100644 --- a/config/application.rb +++ b/config/application.rb @@ -34,6 +34,9 @@ end module Openfoodnetwork class Application < Rails::Application + # Store a description of the current version, with linebreak trimmed + config.x.git_version = `git describe --tags --dirty=-modified`.strip + config.after_initialize do # We need this here because the test env file loads before the Spree engine is loaded Spree::Core::Engine.routes.default_url_options[:host] = ENV["SITE_URL"] if Rails.env == 'test'