feat(tag): add binding and API method for git_tag_target_id (#32)

This commit is contained in:
Aleksey Kulikov 2022-01-13 14:51:23 +03:00 committed by GitHub
parent 6bdf133f06
commit 02ac220d46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View file

@ -65,6 +65,10 @@ Pointer<git_object> target(Pointer<git_tag> tag) {
/// Get the type of a tag's tagged object. /// Get the type of a tag's tagged object.
int targetType(Pointer<git_tag> tag) => libgit2.git_tag_target_type(tag); int targetType(Pointer<git_tag> tag) => libgit2.git_tag_target_type(tag);
/// Get the OID of the tagged object of a tag.
Pointer<git_oid> targetOid(Pointer<git_tag> tag) =>
libgit2.git_tag_target_id(tag);
/// Get the id of a tag. /// Get the id of a tag.
Pointer<git_oid> id(Pointer<git_tag> tag) => libgit2.git_tag_id(tag); Pointer<git_oid> id(Pointer<git_tag> tag) => libgit2.git_tag_id(tag);

View file

@ -137,6 +137,9 @@ class Tag {
} }
} }
/// [Oid] of the tagged object of a tag.
Oid get targetOid => Oid(bindings.targetOid(_tagPointer));
/// [Oid] of a tag. /// [Oid] of a tag.
Oid get oid => Oid(bindings.id(_tagPointer)); Oid get oid => Oid(bindings.id(_tagPointer));

View file

@ -70,7 +70,8 @@ void main() {
time: 1234, time: 1234,
); );
const tagName = 'tag'; const tagName = 'tag';
final target = repo['f17d0d48eae3aa08cecf29128a35e310c97b3521']; const targetSHA = 'f17d0d48eae3aa08cecf29128a35e310c97b3521';
final target = repo[targetSHA];
const message = 'init tag\n'; const message = 'init tag\n';
final oid = repo.createTag( final oid = repo.createTag(
@ -88,6 +89,7 @@ void main() {
expect(newTag.oid.sha, '131a5eb6b7a880b5096c550ee7351aeae7b95a42'); expect(newTag.oid.sha, '131a5eb6b7a880b5096c550ee7351aeae7b95a42');
expect(newTag.name, tagName); expect(newTag.name, tagName);
expect(newTag.message, message); expect(newTag.message, message);
expect(newTag.targetOid.sha, targetSHA);
expect(tagger, signature); expect(tagger, signature);
expect(newTagTarget.oid, target); expect(newTagTarget.oid, target);