Files
openfoodnetwork/lib/git_utils.rb
David Cook febe6501c0 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.
2023-07-28 12:07:52 +10:00

16 lines
478 B
Ruby

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