Skip to content

Commit

Permalink
Merge pull request #839 from HParker/each_key-returns-keys-without-ar…
Browse files Browse the repository at this point in the history
…rays

each_key returns individual keys not wrapped in an internal array
  • Loading branch information
carlosmn committed Apr 9, 2020
2 parents 068075a + cbf0523 commit 5d7dee5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ext/rugged/rugged_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static int cb_config__each_key(const git_config_entry *entry, void *payload)
{
int *exception = (int *) payload;

rb_protect(rb_yield, rb_ary_new3(1, rb_str_new_utf8(entry->name)), exception);
rb_protect(rb_yield, rb_str_new_utf8(entry->name), exception);

return (*exception != 0) ? GIT_EUSER : GIT_OK;
}
Expand Down
15 changes: 15 additions & 0 deletions test/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ def test_snapshot
assert_nil snapshot['new.value']
end

def test_each_key_is_a_string
config = @repo.config
config.each_key do |key|
assert key.is_a?(String)
end
end

def test_each_pair_is_pairs
config = @repo.config
config.each_pair do |key, value|
assert key.is_a?(String)
assert value.is_a?(String)
end
end

def test_transaction
config = Rugged::Config.new(File.join(@repo.path, 'config'))
config['section.name'] = 'value'
Expand Down

0 comments on commit 5d7dee5

Please sign in to comment.