TeapotSourceTeapotCommandFetch

class Fetch

A command to fetch remote packages and dependencies.

Nested

Definitions

def context

Get the context for this command.

Signature

returns Context

The current context.

Implementation

def context
	parent.context
end

def call

Update packages by pulling latest changes from their git remotes, subject to lock file constraints.

Implementation

def call
	selection = context.select
	
	packages = selection.configuration.packages
	
	if specified_packages = self.packages
		packages = packages.slice(specified_packages)
	end
	
	logger = parent.logger
	
	# If no additional packages were resolved, we have reached a fixed point:
	while packages.any?
		packages.each do |package|
			fetch_package(context, selection.configuration, package, logger, **@options)
		end
		
		selection = context.select
		
		# If there are no unresolved packages, we are done.
		if selection.unresolved.empty?
			break
		end
		
		packages = selection.unresolved
	end
	
	if selection.unresolved.count > 0
		logger.error(self) do |buffer|
			buffer.puts "Could not fetch all packages!"
			
			selection.unresolved.each do |package|
				buffer.puts "\t#{package}"
			end
		end
	else
		logger.info "Completed fetch successfully."
	end
end