aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/formula.rb
diff options
context:
space:
mode:
authorVlad Shablinsky2016-07-13 10:11:59 +0300
committerXu Cheng2016-07-16 20:39:13 +0800
commit2e916110e4c561b3e4175da099fc795e85ddb822 (patch)
treeb7edc24e977fc8a3f3d14212e0d15cac57eab137 /Library/Homebrew/formula.rb
parent8a968a0b60dbc78f9f48be76762c9f050fa6416d (diff)
downloadbrew-2e916110e4c561b3e4175da099fc795e85ddb822.tar.bz2
Use HeadVersion for install/reinstall
Diffstat (limited to 'Library/Homebrew/formula.rb')
-rw-r--r--Library/Homebrew/formula.rb22
1 files changed, 21 insertions, 1 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index 4cb584525..aa66bbb49 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -287,6 +287,14 @@ class Formula
active_spec.version
end
+ def update_head_version
+ return unless head?
+ return unless head.downloader.is_a?(VCSDownloadStrategy)
+ return unless head.downloader.cached_location.exist?
+
+ head.version.update_commit(head.downloader.last_commit)
+ end
+
# The {PkgVersion} for this formula with {version} and {#revision} information.
def pkg_version
PkgVersion.new(version, revision)
@@ -405,11 +413,23 @@ class Formula
Pathname.new("#{HOMEBREW_LIBRARY}/LinkedKegs/#{name}")
end
+ def latest_head_prefix
+ head_versions = installed_prefixes.map do |pn|
+ pn_pkgversion = PkgVersion.parse(pn.basename.to_s)
+ pn_pkgversion if pn_pkgversion.head?
+ end.compact
+
+ latest_head_version = head_versions.max_by do |pn_pkgversion|
+ [Tab.for_keg(prefix(pn_pkgversion)).source_modified_time, pn_pkgversion.revision]
+ end
+ prefix(latest_head_version) if latest_head_version
+ end
+
# The latest prefix for this formula. Checks for {#head}, then {#devel}
# and then {#stable}'s {#prefix}
# @private
def installed_prefix
- if head && (head_prefix = prefix(PkgVersion.new(head.version, revision))).directory?
+ if head && (head_prefix = latest_head_prefix) && head_prefix.directory?
head_prefix
elsif devel && (devel_prefix = prefix(PkgVersion.new(devel.version, revision))).directory?
devel_prefix