Skip to content

Commit 8b6a364

Browse files
committed
commit, tag: return a single nil on unsigned objects
Instead of returning a tuple with nils, or the unsigned data, return a single nil when the commit or tag is unsigned.
1 parent 70bca72 commit 8b6a364

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

ext/rugged/rugged_commit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ static VALUE rb_git_commit_header(VALUE self)
625625
static VALUE rb_git_commit_extract_signature(int argc, VALUE *argv, VALUE self)
626626
{
627627
int error;
628-
VALUE ret_arr;
628+
VALUE ret;
629629
git_oid commit_id;
630630
const char *field;
631631
git_repository *repo;
@@ -648,18 +648,18 @@ static VALUE rb_git_commit_extract_signature(int argc, VALUE *argv, VALUE self)
648648
}
649649

650650
if (error == GIT_ENOTFOUND && giterr_last()->klass == GITERR_OBJECT ) {
651-
ret_arr = rb_ary_new3(2, Qnil, Qnil);
651+
ret = Qnil;
652652
} else {
653653
rugged_exception_check(error);
654654

655-
ret_arr = rb_ary_new3(2, rb_str_new(signature.ptr, signature.size),
656-
rb_str_new(signed_data.ptr, signed_data.size));
655+
ret = rb_ary_new3(2, rb_str_new(signature.ptr, signature.size),
656+
rb_str_new(signed_data.ptr, signed_data.size));
657657
}
658658

659659
git_buf_free(&signature);
660660
git_buf_free(&signed_data);
661661

662-
return ret_arr;
662+
return ret;
663663
}
664664

665665
void Init_rugged_commit(void)

lib/rugged/tag.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def self.extract_signature(repo, oid, prefix=GPG_SIGNATURE_PREFIX)
1515
object.data.byteslice(0...index)
1616
]
1717
else
18-
[nil, object.data]
18+
nil
1919
end
2020
end
2121

test/commit_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def test_extract_signature
272272
assert_equal exp_signature, signature
273273
assert_equal exp_signed_data, signed_data
274274

275-
assert_equal [nil, nil], Rugged::Commit.extract_signature(@repo, "8496071c1b46c854b31185ea97743be6a8774479")
275+
assert_nil Rugged::Commit.extract_signature(@repo, "8496071c1b46c854b31185ea97743be6a8774479")
276276

277277
# Ask for a tree
278278
assert_raises(Rugged::InvalidError) { Rugged::Commit.extract_signature(@repo, "181037049a54a1eb5fab404658a3a250b44335d7") }

0 commit comments

Comments
 (0)