lib/teapot/command/fetch.rb in teapot-2.0.0.pre.rc3 vs lib/teapot/command/fetch.rb in teapot-2.0.0
- old
+ new
@@ -115,10 +115,15 @@
unless destination_path.exist?
destination_path.make_symlink(local_path)
end
end
+
+ def credentials(url, username, types)
+ # We should prompt for username/password if required...
+ return Rugged::Credentials::SshKeyFromAgent.new(username: username)
+ end
def clone_or_pull_package(context, configuration, package, package_lock, logger)
logger.info "Processing #{package}...".color(:cyan)
# Where we are going to put the package:
@@ -147,11 +152,11 @@
# Are there uncommitted changes in the work tree?
if repository.to_enum(:status).any?
raise FetchError.new(package, "Uncommited local modifications")
end
- repository.fetch('origin')
+ repository.fetch('origin', credentials: self.method(:credentials))
repository.checkout(branch_name)
# Essentially implement git pull:
if commit_id
# Lookup the named branch:
@@ -168,10 +173,10 @@
logger.info "Cloning package at path #{destination_path}...".color(:cyan)
external_url = package.external_url(context.root)
# Clone the repository with the specified branch:
- repository = Rugged::Repository.clone_at(external_url.to_s, destination_path.to_s, checkout_branch: branch_name)
+ repository = Rugged::Repository.clone_at(external_url.to_s, destination_path.to_s, checkout_branch: branch_name, credentials: self.method(:credentials))
# Reset it to the requested commit if required:
repository.reset(commit_id, :hard) if commit_id
end