diff --git a/Classes/Controllers/PBRefController.h b/Classes/Controllers/PBRefController.h index a9c11f4c2..373312b43 100644 --- a/Classes/Controllers/PBRefController.h +++ b/Classes/Controllers/PBRefController.h @@ -23,6 +23,7 @@ IBOutlet NSPopUpButton *branchPopUp; } +- (void) pruneRemote:(PBRefMenuItem *)sender; - (void) fetchRemote:(PBRefMenuItem *)sender; - (void) pullRemote:(PBRefMenuItem *)sender; - (void) pushUpdatesToRemote:(PBRefMenuItem *)sender; diff --git a/Classes/Controllers/PBRefController.m b/Classes/Controllers/PBRefController.m index 9be1fd8cc..7ddf52d89 100644 --- a/Classes/Controllers/PBRefController.m +++ b/Classes/Controllers/PBRefController.m @@ -29,6 +29,16 @@ - (void)awakeFromNib [commitList registerForDraggedTypes:[NSArray arrayWithObject:@"PBGitRef"]]; } +#pragma mark Prune + +- (void) pruneRemote:(PBRefMenuItem *)sender +{ + id refish = [sender refish]; + if ([refish refishType] == kGitXCommitType) + return; + + [historyController.repository beginPruneRemoteForRef:refish]; +} #pragma mark Fetch diff --git a/Classes/Views/PBRefMenuItem.m b/Classes/Views/PBRefMenuItem.m index 721d9aaad..cc5a49c8d 100644 --- a/Classes/Views/PBRefMenuItem.m +++ b/Classes/Views/PBRefMenuItem.m @@ -130,6 +130,13 @@ + (NSArray *) defaultMenuItemsForRef:(PBGitRef *)ref inRepository:(PBGitReposito } } + if (isRemote) { + // prune + [items addObject:[PBRefMenuItem separatorItem]]; + NSString *pruneTitle = [NSString stringWithFormat:@"Prune %@", remoteName]; + [items addObject:[PBRefMenuItem itemWithTitle:pruneTitle action:@selector(pruneRemote:) enabled:YES]]; + } + // delete ref [items addObject:[PBRefMenuItem separatorItem]]; { diff --git a/Classes/git/PBGitRepository.h b/Classes/git/PBGitRepository.h index 2cda588f4..0bf2f585e 100644 --- a/Classes/git/PBGitRepository.h +++ b/Classes/git/PBGitRepository.h @@ -70,6 +70,7 @@ static NSString * PBStringFromBranchFilterType(PBGitXBranchFilterType type) { - (void) cloneRepositoryToPath:(NSString *)path bare:(BOOL)isBare; - (void) beginAddRemote:(NSString *)remoteName forURL:(NSString *)remoteURL; +- (void) beginPruneRemoteForRef:(PBGitRef *)ref; - (void) beginFetchFromRemoteForRef:(PBGitRef *)ref; - (void) beginPullFromRemote:(PBGitRef *)remoteRef forRef:(PBGitRef *)ref; - (void) beginPushRef:(PBGitRef *)ref toRemote:(PBGitRef *)remoteRef; diff --git a/Classes/git/PBGitRepository.m b/Classes/git/PBGitRepository.m index 7d1082a7c..23ef277b9 100644 --- a/Classes/git/PBGitRepository.m +++ b/Classes/git/PBGitRepository.m @@ -623,6 +623,27 @@ - (void) beginAddRemote:(NSString *)remoteName forURL:(NSString *)remoteURL [PBRemoteProgressSheet beginRemoteProgressSheetForArguments:arguments title:title description:description inRepository:self]; } +- (void) beginPruneRemoteForRef:(PBGitRef *)ref +{ + NSMutableArray *arguments = [NSMutableArray arrayWithObject:@"prune"]; + + if (![ref isRemote]) { + NSError *error = nil; + ref = [self remoteRefForBranch:ref error:&error]; + if (!ref) { + if (error) + [self.windowController showErrorSheet:error]; + return; + } + } + NSString *remoteName = [ref remoteName]; + [arguments addObject:remoteName]; + + NSString *description = [NSString stringWithFormat:@"Deleting all stale remote-tracking branches from %@", remoteName]; + NSString *title = @"Pruning remote"; + [PBRemoteProgressSheet beginRemoteProgressSheetForArguments:arguments title:title description:description inRepository:self]; +} + - (void) beginFetchFromRemoteForRef:(PBGitRef *)ref { NSMutableArray *arguments = [NSMutableArray arrayWithObject:@"fetch"];