diff options
| author | Max Howell | 2012-08-10 16:06:51 -0400 |
|---|---|---|
| committer | Max Howell | 2012-08-29 12:41:33 -0400 |
| commit | 50767c60773b290eb8d203695852a6a0c21c71e4 (patch) | |
| tree | 350492373da4f93cc528b93637be57d71d394db0 /Library/Homebrew | |
| parent | 05991dd846ac54b10cd78453b140de8bfb259392 (diff) | |
| download | brew-50767c60773b290eb8d203695852a6a0c21c71e4.tar.bz2 | |
Record HEAD SHA and date of installs in receipt
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/extend/string.rb | 11 | ||||
| -rw-r--r-- | Library/Homebrew/tab.rb | 19 |
2 files changed, 24 insertions, 6 deletions
diff --git a/Library/Homebrew/extend/string.rb b/Library/Homebrew/extend/string.rb index 16171310b..e9f475b6e 100644 --- a/Library/Homebrew/extend/string.rb +++ b/Library/Homebrew/extend/string.rb @@ -21,6 +21,17 @@ class String self[0, prefix.length] == prefix 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 # used by the inreplace function (in utils.rb) diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index e28ce1eda..15f2911d9 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -9,17 +9,19 @@ require 'vendor/multi_json' # `Tab.for_install`. class Tab < OpenStruct 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), :unused_options => args.unused_options(f), :tabfile => f.prefix + "INSTALL_RECEIPT.json", :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 def self.from_file path tab = Tab.new MultiJson.decode(open(path).read) tab.tabfile = path - return tab end @@ -35,7 +37,9 @@ class Tab < OpenStruct Tab.new :used_options => [], :unused_options => [], :built_as_bottle => false, - :tapped_from => "" + :tapped_from => "", + :time => nil, + :HEAD => nil end end end @@ -63,7 +67,9 @@ class Tab < OpenStruct Tab.new :used_options => [], :unused_options => f.build.as_flags, :built_as_bottle => false, - :tapped_from => "" + :tapped_from => "", + :time => nil, + :HEAD => nil end def installed_with? opt @@ -79,8 +85,9 @@ class Tab < OpenStruct :used_options => used_options, :unused_options => unused_options, :built_as_bottle => built_as_bottle, - :tapped_from => tapped_from - }) + :tapped_from => tapped_from, + :time => time, + :HEAD => send("HEAD")}) end def write |
