Use HeadVersion for install/reinstall
This commit is contained in:
		
							parent
							
								
									8a968a0b60
								
							
						
					
					
						commit
						2e916110e4
					
				@ -135,6 +135,8 @@ class VCSDownloadStrategy < AbstractDownloadStrategy
 | 
			
		||||
      clone_repo
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    version.update_commit(last_commit) if head?
 | 
			
		||||
 | 
			
		||||
    if @ref_type == :tag && @revision && current_revision
 | 
			
		||||
      unless current_revision == @revision
 | 
			
		||||
        raise <<-EOS.undent
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -586,6 +586,8 @@ class FormulaInstaller
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    formula.update_head_version
 | 
			
		||||
 | 
			
		||||
    if !formula.prefix.directory? || Keg.new(formula.prefix).empty_installation?
 | 
			
		||||
      raise "Empty installation"
 | 
			
		||||
    end
 | 
			
		||||
@ -593,6 +595,7 @@ class FormulaInstaller
 | 
			
		||||
  rescue Exception
 | 
			
		||||
    ignore_interrupts do
 | 
			
		||||
      # any exceptions must leave us with nothing installed
 | 
			
		||||
      formula.update_head_version
 | 
			
		||||
      formula.prefix.rmtree if formula.prefix.directory?
 | 
			
		||||
      formula.rack.rmdir_if_possible
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
@ -5,6 +5,8 @@ class PkgVersion
 | 
			
		||||
 | 
			
		||||
  RX = /\A(.+?)(?:_(\d+))?\z/
 | 
			
		||||
 | 
			
		||||
  attr_reader :version, :revision
 | 
			
		||||
 | 
			
		||||
  def self.parse(path)
 | 
			
		||||
    _, version, revision = *path.match(RX)
 | 
			
		||||
    version = Version.create(version)
 | 
			
		||||
@ -38,8 +40,4 @@ class PkgVersion
 | 
			
		||||
  def hash
 | 
			
		||||
    version.hash ^ revision.hash
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  protected
 | 
			
		||||
 | 
			
		||||
  attr_reader :version, :revision
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -29,6 +29,7 @@ class SoftwareSpec
 | 
			
		||||
  def_delegators :@resource, :cached_download, :clear_cache
 | 
			
		||||
  def_delegators :@resource, :checksum, :mirrors, :specs, :using
 | 
			
		||||
  def_delegators :@resource, :version, :mirror, *Checksum::TYPES
 | 
			
		||||
  def_delegators :@resource, :downloader
 | 
			
		||||
 | 
			
		||||
  def initialize
 | 
			
		||||
    @resource = Resource.new
 | 
			
		||||
@ -203,7 +204,7 @@ end
 | 
			
		||||
class HeadSoftwareSpec < SoftwareSpec
 | 
			
		||||
  def initialize
 | 
			
		||||
    super
 | 
			
		||||
    @resource.version = Version.new("HEAD")
 | 
			
		||||
    @resource.version = HeadVersion.new("HEAD")
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def verify_download_integrity(_fn)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user