Repository navigation
Fix for #336 #338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for #336 #338
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -452,7 +452,7 @@ static int rugged__default_remote_credentials_cb( | |
| static void parse_clone_options(git_clone_options *ret, VALUE rb_options_hash, struct rugged_remote_cb_payload *remote_payload) | ||
| { | ||
| git_remote_callbacks remote_callbacks = GIT_REMOTE_CALLBACKS_INIT; | ||
| VALUE val; | ||
| VALUE val, checkout_branch_val; | ||
|
|
||
| if (NIL_P(rb_options_hash)) | ||
| return; | ||
|
|
@@ -461,6 +461,10 @@ static void parse_clone_options(git_clone_options *ret, VALUE rb_options_hash, s | |
| if (RTEST(val)) | ||
| ret->bare = 1; | ||
|
|
||
| checkout_branch_val = rb_hash_aref(rb_options_hash, CSTR2SYM("checkout_branch")); | ||
| if (RTEST(checkout_branch_val) && (TYPE(checkout_branch_val) == T_STRING)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, I feel that something like the following would be a bit better: |
||
| ret->checkout_branch = StringValuePtr(checkout_branch_val); | ||
|
|
||
| val = rb_hash_aref(rb_options_hash, CSTR2SYM("credentials")); | ||
| if (RTEST(val)) { | ||
| if (rb_obj_is_kind_of(val, rb_cRuggedCredPlaintext) || | ||
|
|
@@ -509,7 +513,7 @@ static void parse_clone_options(git_clone_options *ret, VALUE rb_options_hash, s | |
| * If +true+, the clone will be created as a bare repository. | ||
| * Defaults to +false+. | ||
| * | ||
| * :branch :: | ||
| * :checkout_branch :: | ||
| * The name of a branch to checkout. Defaults to the remote's +HEAD+. | ||
| * | ||
| * :remote :: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -450,6 +450,19 @@ def test_clone_with_progress | |
| assert_equal 1563, received_bytes | ||
| end | ||
|
|
||
| def test_clone_with_branch | ||
| repo = Rugged::Repository.clone_at(@source_path, @tmppath, {:checkout_branch => "packed"}) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you change this to the Ruby 1.9 Hash Syntax? Like: |
||
| begin | ||
| assert_equal "what file?\n", File.read(File.join(@tmppath, "second.txt")) | ||
| assert_equal "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9", repo.head.target_id | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be enough if you check that: The other assertions you have in this test don't really have anything to do with the |
||
| assert_equal "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9", repo.ref("refs/heads/packed").target_id | ||
| assert_equal "36060c58702ed4c2a40832c51758d5344201d89a", repo.ref("refs/remotes/origin/master").target_id | ||
| assert_equal "41bc8c69075bbdb46c5c6f0566cc8cc5b46e8bd9", repo.ref("refs/remotes/origin/packed").target_id | ||
| ensure | ||
| repo.close | ||
| end | ||
| end | ||
|
|
||
| def test_clone_quits_on_error | ||
| begin | ||
| Rugged::Repository.clone_at(@source_path, @tmppath, :callbacks => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you just reuse
valhere, instead of introducing another variable?