Skip to content

Commit f09f1c6

Browse files
committed
wrap git_remote_delete
1 parent 4673546 commit f09f1c6

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ObjectiveGit/GTRepository.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,13 @@ typedef NS_ENUM(NSInteger, GTRepositoryStateType) {
357357
/// returns an array of NSStrings holding the names of the remotes, or nil if an error occurred
358358
- (nullable NSArray<NSString *> *)remoteNamesWithError:(NSError **)error;
359359

360+
/// Delete the given remote by name
361+
///
362+
/// error - If not NULL, set to any error that occurs.
363+
///
364+
/// returns YES if the deletion succeeded, otherwise NO.
365+
- (BOOL)deleteRemoteNamed:(NSString *)remoteName error:(NSError **)error;
366+
360367
/// Get all tags in the repository.
361368
///
362369
/// error - If not NULL, set to any error that occurs.

ObjectiveGit/GTRepository.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,16 @@ - (NSArray *)remoteNamesWithError:(NSError **)error {
466466
return remoteNames;
467467
}
468468

469+
- (BOOL)deleteRemoteNamed:(NSString *)remoteName error:(NSError **)error {
470+
int gitError = git_remote_delete(self.git_repository, [remoteName cStringUsingEncoding:NSUTF8StringEncoding]);
471+
if (gitError < GIT_OK) {
472+
if (error != NULL) *error = [NSError git_errorFor:gitError description:@"Failed to delete remote."];
473+
return NO;
474+
}
475+
476+
return YES;
477+
}
478+
469479
struct GTRepositoryTagEnumerationInfo {
470480
__unsafe_unretained GTRepository *myself;
471481
__unsafe_unretained GTRepositoryTagEnumerationBlock block;

0 commit comments

Comments
 (0)