From 02ac220d46335699009a81de2357c8ce404cf2b6 Mon Sep 17 00:00:00 2001 From: Aleksey Kulikov Date: Thu, 13 Jan 2022 14:51:23 +0300 Subject: [PATCH] feat(tag): add binding and API method for git_tag_target_id (#32) --- lib/src/bindings/tag.dart | 4 ++++ lib/src/tag.dart | 3 +++ test/tag_test.dart | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/src/bindings/tag.dart b/lib/src/bindings/tag.dart index 31e1fec..4210428 100644 --- a/lib/src/bindings/tag.dart +++ b/lib/src/bindings/tag.dart @@ -65,6 +65,10 @@ Pointer target(Pointer tag) { /// Get the type of a tag's tagged object. int targetType(Pointer tag) => libgit2.git_tag_target_type(tag); +/// Get the OID of the tagged object of a tag. +Pointer targetOid(Pointer tag) => + libgit2.git_tag_target_id(tag); + /// Get the id of a tag. Pointer id(Pointer tag) => libgit2.git_tag_id(tag); diff --git a/lib/src/tag.dart b/lib/src/tag.dart index 569c91f..e7c9d10 100644 --- a/lib/src/tag.dart +++ b/lib/src/tag.dart @@ -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 get oid => Oid(bindings.id(_tagPointer)); diff --git a/test/tag_test.dart b/test/tag_test.dart index 02b5496..6654ef0 100644 --- a/test/tag_test.dart +++ b/test/tag_test.dart @@ -70,7 +70,8 @@ void main() { time: 1234, ); const tagName = 'tag'; - final target = repo['f17d0d48eae3aa08cecf29128a35e310c97b3521']; + const targetSHA = 'f17d0d48eae3aa08cecf29128a35e310c97b3521'; + final target = repo[targetSHA]; const message = 'init tag\n'; final oid = repo.createTag( @@ -88,6 +89,7 @@ void main() { expect(newTag.oid.sha, '131a5eb6b7a880b5096c550ee7351aeae7b95a42'); expect(newTag.name, tagName); expect(newTag.message, message); + expect(newTag.targetOid.sha, targetSHA); expect(tagger, signature); expect(newTagTarget.oid, target);