def self.commit_date_version(use_local_git = false)
if use_local_git
unless git_available?
raise RuntimeError,
"GVB.commit_date_version(use_local_git=true) called, but git isn't installed"
end
sq_git_dir = shell_quoted_string(Dir.pwd)
else
sq_git_dir = shell_quoted_string((File.dirname(caller_file) rescue nil || Dir.pwd))
end
commit_dates = `git -C #{sq_git_dir} log --format=%at`.
split("\n").
map { |l| Time.at(Integer(l)).strftime("%Y%m%d") }
if $? == 0
version_date = commit_dates.first
commit_count = commit_dates.select { |d| d == version_date }.length - 1
dirty_suffix = if dirty_tree?
".dirty.#{Time.now.strftime("%Y%m%d.%H%M%S")}"
else
""
end
return "0.#{version_date}.#{commit_count}#{dirty_suffix}"
end
system("git -C #{sq_git_dir} status > #{DEVNULL} 2>&1")
$? == 0 ? "0.0.0.1.ENOCOMMITS" : gem_version(use_local_git)
end