forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.rb
44 lines (40 loc) · 1.35 KB
/
version.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require 'rbconfig'
require 'yaml'
require 'open3'
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
# Fallback to using Git version detection if version_yml not present
changed_files = %w[git rev-parse --short HEAD]
begin
# stderr may contain Git warnings that we can ignore
output, _stderr, status = ::Open3.capture3(*changed_files, chdir: root)
hash = "-#{output}" if status.success?
rescue => e
elog(e) if defined?(elog)
end
end
hash.strip
end
end
VERSION = "6.3.36"
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