diff options
| author | Vlad Shablinsky | 2016-07-22 12:58:24 +0300 |
|---|---|---|
| committer | Xu Cheng | 2016-08-06 21:25:56 +0800 |
| commit | 1b88c2912b9e0fb9b03580da3707ec36e2d0c888 (patch) | |
| tree | dd09b7936990ac4b34ad167e0860eb8904683f62 /Library | |
| parent | 00f37d67787ff5e06e754680d23ea015699ea6f7 (diff) | |
| download | brew-1b88c2912b9e0fb9b03580da3707ec36e2d0c888.tar.bz2 | |
formula: add new HEAD methods
* add `latest_head_version` to return latest HEAD version installed
* add `latest_head_prefix` to return Pathname with latest HEAD version
* add `head_version_outdated?` to check if HEAD version is up-to-date
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/formula.rb | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index a9416586f..d0476ec26 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -413,16 +413,36 @@ class Formula Pathname.new("#{HOMEBREW_LIBRARY}/LinkedKegs/#{name}") end - def latest_head_prefix + def latest_head_version 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| + 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 + + def latest_head_prefix + head_version = latest_head_version + prefix(head_version) if head_version + end + + def head_version_outdated?(version, options={}) + tab = Tab.for_keg(prefix(version)) + + return true if stable && tab.stable_version && tab.stable_version < stable.version + return true if devel && tab.devel_version && tab.devel_version < devel.version + + if options[:fetch_head] + return false unless head && head.downloader.is_a?(VCSDownloadStrategy) + downloader = head.downloader + downloader.shutup! unless ARGV.verbose? + downloader.commit_outdated?(version.version.commit) + else + false + end end # The latest prefix for this formula. Checks for {#head}, then {#devel} |
