TeapotSourceTeapotCommandClone

class Clone

A command to clone a remote repository and fetch all dependencies.

Definitions

def call

Clone packages from their remote repositories using git, parallelizing the operations.

Implementation

def call
	logger = parent.logger
	
	name = File.basename(::Build::URI[@source].path, ".git")
	
	nested = parent["--root", parent.options[:root] || name]
	root = nested.root
	
	if root.exist?
		raise ArgumentError.new("#{root} already exists!")
	end
	
	logger.info "Cloning #{@source} to #{root}..."
	_repository = Rugged::Repository.clone_at(@source, root.to_s, credentials: self.method(:credentials))
	
	# Fetch the initial packages:
	Fetch[parent: nested].call
end

def credentials(url, username, types)

Provide credentials for repository authentication.

Signature

parameter url String

The repository URL.

parameter username String

The username.

parameter types Array

The credential types allowed.

returns Rugged::Credentials

The credentials object.

Implementation

def credentials(url, username, types)
	# We should prompt for username/password if required...
	return Rugged::Credentials::SshKeyFromAgent.new(username: username)
end