Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit fb5be5c

Browse files
committed
config/initializers: don't use mkmf
To determine whether "git" is on the system, we used the mkmf library. This has turned out to not be the best option because then a "mkmf.log" file is always generated. Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
1 parent c1fb8c3 commit fb5be5c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

config/initializers/version.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
require 'mkmf'
2-
31
# Version module
42
# Makes the app version available to the application itself
53
# Needs the git executable for all git operations
64
module Version
7-
git = find_executable('git')
8-
BRANCH = git ? `git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3 2>/dev/null`.chomp : nil
9-
COMMIT = git ? `git log --pretty=format:'%h' -n 1 2>/dev/null`.chomp : nil
10-
TAG = git ? `git tag --points-at $(git rev-parse HEAD) 2>/dev/null`.chomp : nil
11-
5+
# Returns true if git is in the system, false otherwise.
6+
def self.git?
7+
paths = ENV["PATH"].split(":")
8+
paths.each { |p| return true if File.executable?(File.join(p, "git")) }
9+
false
10+
end
11+
12+
BRANCH = Version.git? ? `git symbolic-ref HEAD 2>/dev/null | cut -d"/" -f 3 2>/dev/null`.chomp : nil
13+
COMMIT = Version.git? ? `git log --pretty=format:'%h' -n 1 2>/dev/null`.chomp : nil
14+
TAG = Version.git? ? `git tag --points-at $(git rev-parse HEAD) 2>/dev/null`.chomp : nil
15+
1216
# Version.value returns the app version
1317
# Priority: git tag > git branch/commit > VERSION file
1418
def self.value

0 commit comments

Comments
 (0)