Record HEAD SHA and date of installs in receipt
This commit is contained in:
parent
05991dd846
commit
50767c6077
@ -21,6 +21,17 @@ class String
|
|||||||
self[0, prefix.length] == prefix
|
self[0, prefix.length] == prefix
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# String.chomp, but if result is empty: returns nil instead.
|
||||||
|
# Allows `chuzzle || foo` short-circuits.
|
||||||
|
def chuzzle
|
||||||
|
s = chomp
|
||||||
|
s unless s.empty?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class NilClass
|
||||||
|
def chuzzle; end
|
||||||
end
|
end
|
||||||
|
|
||||||
# used by the inreplace function (in utils.rb)
|
# used by the inreplace function (in utils.rb)
|
||||||
|
|||||||
@ -9,17 +9,19 @@ require 'vendor/multi_json'
|
|||||||
# `Tab.for_install`.
|
# `Tab.for_install`.
|
||||||
class Tab < OpenStruct
|
class Tab < OpenStruct
|
||||||
def self.for_install f, args
|
def self.for_install f, args
|
||||||
|
sha = `cd '#{HOMEBREW_REPOSITORY}' && git rev-parse --verify -q HEAD 2>/dev/null`.chuzzle
|
||||||
Tab.new :used_options => args.used_options(f),
|
Tab.new :used_options => args.used_options(f),
|
||||||
:unused_options => args.unused_options(f),
|
:unused_options => args.unused_options(f),
|
||||||
:tabfile => f.prefix + "INSTALL_RECEIPT.json",
|
:tabfile => f.prefix + "INSTALL_RECEIPT.json",
|
||||||
:built_as_bottle => !!args.build_bottle?,
|
:built_as_bottle => !!args.build_bottle?,
|
||||||
:tapped_from => f.tap
|
:tapped_from => f.tap,
|
||||||
|
:time => Time.now.to_i, # to_s would be better but Ruby has no from_s function :P
|
||||||
|
:HEAD => sha
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_file path
|
def self.from_file path
|
||||||
tab = Tab.new MultiJson.decode(open(path).read)
|
tab = Tab.new MultiJson.decode(open(path).read)
|
||||||
tab.tabfile = path
|
tab.tabfile = path
|
||||||
|
|
||||||
return tab
|
return tab
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -35,7 +37,9 @@ class Tab < OpenStruct
|
|||||||
Tab.new :used_options => [],
|
Tab.new :used_options => [],
|
||||||
:unused_options => [],
|
:unused_options => [],
|
||||||
:built_as_bottle => false,
|
:built_as_bottle => false,
|
||||||
:tapped_from => ""
|
:tapped_from => "",
|
||||||
|
:time => nil,
|
||||||
|
:HEAD => nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -63,7 +67,9 @@ class Tab < OpenStruct
|
|||||||
Tab.new :used_options => [],
|
Tab.new :used_options => [],
|
||||||
:unused_options => f.build.as_flags,
|
:unused_options => f.build.as_flags,
|
||||||
:built_as_bottle => false,
|
:built_as_bottle => false,
|
||||||
:tapped_from => ""
|
:tapped_from => "",
|
||||||
|
:time => nil,
|
||||||
|
:HEAD => nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def installed_with? opt
|
def installed_with? opt
|
||||||
@ -79,8 +85,9 @@ class Tab < OpenStruct
|
|||||||
:used_options => used_options,
|
:used_options => used_options,
|
||||||
:unused_options => unused_options,
|
:unused_options => unused_options,
|
||||||
:built_as_bottle => built_as_bottle,
|
:built_as_bottle => built_as_bottle,
|
||||||
:tapped_from => tapped_from
|
:tapped_from => tapped_from,
|
||||||
})
|
:time => time,
|
||||||
|
:HEAD => send("HEAD")})
|
||||||
end
|
end
|
||||||
|
|
||||||
def write
|
def write
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user