Skip to content

Commit 9ffb9a1

Browse files
committed
Add -[GTTag delete:]
1 parent c19cc87 commit 9ffb9a1

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

ObjectiveGit/GTTag.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ NS_ASSUME_NONNULL_BEGIN
5959
/// Returns the found object or nil on error.
6060
- (id _Nullable)objectByPeelingTagError:(NSError **)error;
6161

62+
/// Delete the receiver.
63+
- (BOOL)delete:(NSError **)error;
64+
6265
/// The underlying `git_object` as a `git_tag` object.
6366
- (git_tag *)git_tag __attribute__((objc_returns_inner_pointer));
6467

ObjectiveGit/GTTag.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,13 @@ - (id)objectByPeelingTagError:(NSError **)error {
8484
return [[GTObject alloc] initWithObj:target inRepository:self.repository];
8585
}
8686

87+
- (BOOL)delete:(NSError **)error {
88+
int gitError = git_tag_delete(self.repository.git_repository, self.name.UTF8String);
89+
if (gitError != GIT_OK) {
90+
if (error) *error = [NSError git_errorFor:gitError description:@"Tag deletion failed"];
91+
return NO;
92+
}
93+
return YES;
94+
}
95+
8796
@end

ObjectiveGitTests/GTTagSpec.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@
3939
expect(signature.email).to(equal(@"[email protected]"));
4040
});
4141

42+
it(@"can delete tags", ^{
43+
NSError *error = nil;
44+
45+
BOOL success = [tag delete:&error];
46+
expect(@(success)).to(beTruthy());
47+
expect(error).to(beNil());
48+
49+
success = [tag delete:&error];
50+
expect(@(success)).to(beFalsy());
51+
expect(error).notTo(beNil());
52+
});
53+
4254
afterEach(^{
4355
[self tearDown];
4456
});

0 commit comments

Comments
 (0)