Class: Teapot::Command::Clone

Inherits:
Samovar::Command
  • Object
show all
Defined in:
lib/teapot/command/clone.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#callObject

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



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/teapot/command/clone.rb', line 23

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

#credentials(url, username, types) ⇒ Object

Provide credentials for repository authentication.



47
48
49
50
# File 'lib/teapot/command/clone.rb', line 47

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