Skip to content

Commit fe891b1

Browse files
committed
add remote branch deletion feature
1 parent 7d8d8fa commit fe891b1

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

ObjectiveGit/GTRepository+RemoteOperations.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,17 @@ extern NSString *const GTRepositoryRemoteOptionsCredentialProvider;
7575
/// will point to an error describing what happened).
7676
- (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(void (^)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock;
7777

78+
/// Delete a remote branch
79+
///
80+
/// branch - The branch to push. Must not be nil.
81+
/// remote - The remote to push to. Must not be nil.
82+
/// options - Options applied to the push operation. Can be NULL.
83+
/// Recognized options are:
84+
/// `GTRepositoryRemoteOptionsCredentialProvider`
85+
/// error - The error if one occurred. Can be NULL.
86+
/// progressBlock - An optional callback for monitoring progress.
87+
///
88+
/// Returns YES if the push was successful, NO otherwise (and `error`, if provided,
89+
/// will point to an error describing what happened).
90+
- (BOOL)deleteBranch:(GTBranch *)branch fromRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(void (^)(unsigned int current, unsigned int total, size_t bytes, BOOL *stop))progressBlock;
7891
@end

ObjectiveGit/GTRepository+RemoteOperations.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,16 @@ - (BOOL)pushBranches:(NSArray *)branches toRemote:(GTRemote *)remote withOptions
196196
return [self pushRefspecs:refspecs toRemote:remote withOptions:options error:error progress:progressBlock];
197197
}
198198

199+
#pragma mark - Deletion (Public)
200+
- (BOOL)deleteBranch:(GTBranch *)branch fromRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(GTRemotePushTransferProgressBlock)progressBlock {
201+
NSParameterAssert(branch != nil);
202+
NSParameterAssert(remote != nil);
203+
204+
NSArray *refspecs = @[[NSString stringWithFormat:@":refs/heads/%@", branch.shortName]];
205+
206+
return [self pushRefspecs:refspecs toRemote:remote withOptions:options error:error progress:progressBlock];
207+
}
208+
199209
#pragma mark - Push (Private)
200210

201211
- (BOOL)pushRefspecs:(NSArray *)refspecs toRemote:(GTRemote *)remote withOptions:(NSDictionary *)options error:(NSError **)error progress:(GTRemotePushTransferProgressBlock)progressBlock {

0 commit comments

Comments
 (0)