metasploit-framework/lib/metasploit/framework/version.rb

43 lines
1.3 KiB
Ruby
Raw Normal View History

require 'rbconfig'
require 'yaml'
module Metasploit
module Framework
module Version
# Determines the git hash for this source tree
#
# @return [String] the git hash for this source tree
def self.get_hash
@@git_hash ||= begin
root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..'))
version_yml = File.join(root, 'version.yml')
hash = ''
if File.exist?(version_yml)
version_info = YAML.load_file(version_yml)
hash = '-' + version_info['build_framework_rev']
else
# determine if git is installed
2015-10-15 21:14:20 +00:00
null = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'NUL' : '/dev/null'
git_installed = system("git --version > #{null} 2>&1")
# get the hash of the HEAD commit
if git_installed && File.exist?(File.join(root, '.git'))
2015-10-15 21:14:20 +00:00
hash = '-' + `git rev-parse --short HEAD`
end
end
hash.strip
end
end
2016-12-09 18:03:22 +00:00
VERSION = "4.13.7"
MAJOR, MINOR, PATCH = VERSION.split('.').map { |x| x.to_i }
PRERELEASE = 'dev'
HASH = get_hash
end
VERSION = "#{Version::VERSION}-#{Version::PRERELEASE}#{Version::HASH}"
GEM_VERSION = "#{Version::VERSION}"
end
end