mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +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:
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