mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Prevent git errors from showing in command output
This would be a very rare case, but one time the git command failed, printing out an obscure "fatal" message to stderr which caused confusion.
This commit is contained in:
@@ -24,6 +24,7 @@ require_relative "../lib/open_food_network/i18n_config"
|
||||
require_relative '../lib/spree/core/environment'
|
||||
require_relative '../lib/spree/core/mail_interceptor'
|
||||
require_relative "../lib/i18n_digests"
|
||||
require_relative "../lib/git_utils"
|
||||
|
||||
if defined?(Bundler)
|
||||
# If you precompile assets before deploying to production, use this line
|
||||
@@ -34,8 +35,8 @@ 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
|
||||
# Store a description of the current version
|
||||
config.x.git_version = GitUtils::git_version
|
||||
|
||||
config.after_initialize do
|
||||
# We need this here because the test env file loads before the Spree engine is loaded
|
||||
|
||||
15
lib/git_utils.rb
Normal file
15
lib/git_utils.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
class GitUtils
|
||||
# Generate a description of the git version based on latest tag.
|
||||
# Eg: "v4.4.4-156-g8afcd82-modified"
|
||||
# - tag name
|
||||
# - number of commits since tag
|
||||
# - commit ID
|
||||
# - "modified" if uncommitted changes
|
||||
#
|
||||
def self.git_version
|
||||
# Capture stderr so that confusing errors aren't shown in comand output
|
||||
stdout, _stderr, _status = Open3.capture3("git describe --tags --dirty=-modified")
|
||||
# Strip trailing linebreak
|
||||
stdout.strip
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user