Class: Teapot::Command::Clone

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

Instance Method Summary collapse

Instance Method Details

#callObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/teapot/command/clone.rb', line 36

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



55
56
57
58
# File 'lib/teapot/command/clone.rb', line 55

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