def self.date(use_local_git=false)
if use_local_git
unless git_available?
raise RuntimeError,
"GVB.date(use_local_git=true), but git is not 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
system("git -C #{sq_git_dir} status > #{DEVNULL} 2>&1")
if $? == 0
if dirty_tree?
return Time.now.strftime("%F")
else
return `git -C #{sq_git_dir} show --no-show-signature --format=format:%cd --date=short`.lines.first.strip
end
else
if use_local_git
raise RuntimeError,
"GVB.date(use_local_git=true) called from non-git location"
end
if spec = caller_gemspec
return spec.date.strftime("%F")
end
raise RuntimeError,
"GVB.date called from mysterious, non-gem location."
end
end