Method: Rugged::Repository.clone_at
- Defined in:
- ext/rugged/rugged_repo.c
permalink .clone_at(url, local_path[, options]) ⇒ Object
Clone a repository from url
to local_path
.
The following options can be passed in the options
Hash:
- :bare
-
If
true
, the clone will be created as a bare repository. Defaults tofalse
. - :checkout_branch
-
The name of a branch to checkout. Defaults to the remote’s
HEAD
. - :remote
-
The name to give to the “origin” remote. Defaults to
"origin"
. - :ignore_cert_errors
-
If set to
true
, errors while validating the remote’s host certificate will be ignored. - :proxy_url
-
The url of an http proxy to use to access the remote repository.
- :credentials
-
The credentials to use for the clone operation. Can be either an instance of one of the Rugged::Credentials types, or a proc returning one of the former. The proc will be called with the
url
, theusername
from the url (if applicable) and a list of applicable credential types. - :progress
-
A callback that will be executed with the textual progress received from the remote. This is the text send over the progress side-band (ie. the “counting objects” output).
- :transfer_progress
-
A callback that will be executed to report clone progress information. It will be passed the amount of
total_objects
,indexed_objects
,received_objects
,local_objects
,total_deltas
,indexed_deltas
, andreceived_bytes
. - :update_tips
-
A callback that will be executed each time a reference was updated locally. It will be passed the
refname
,old_oid
andnew_oid
.
Example:
Repository.clone_at("https://github.com/libgit2/rugged.git", "./some/dir", {
transfer_progress: lambda { |total_objects, indexed_objects, received_objects, local_objects, total_deltas, indexed_deltas, received_bytes|
# ...
}
})
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 |
# File 'ext/rugged/rugged_repo.c', line 587
static VALUE rb_git_repo_clone_at(int argc, VALUE *argv, VALUE klass)
{
VALUE url, local_path, rb_options_hash;
git_clone_options options = GIT_CLONE_OPTIONS_INIT;
struct rugged_remote_cb_payload remote_payload = { Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, Qnil, 0 };
git_repository *repo;
int error;
rb_scan_args(argc, argv, "21", &url, &local_path, &rb_options_hash);
Check_Type(url, T_STRING);
FilePathValue(local_path);
parse_clone_options(&options, rb_options_hash, &remote_payload);
error = git_clone(&repo, StringValueCStr(url), StringValueCStr(local_path), &options);
if (RTEST(remote_payload.exception))
rb_jump_tag(remote_payload.exception);
rugged_exception_check(error);
return rugged_repo_new(klass, repo);
}
|