Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement git remote prune command #262

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Classes/Controllers/PBRefController.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
IBOutlet NSPopUpButton *branchPopUp;
}

- (void) pruneRemote:(PBRefMenuItem *)sender;
- (void) fetchRemote:(PBRefMenuItem *)sender;
- (void) pullRemote:(PBRefMenuItem *)sender;
- (void) pushUpdatesToRemote:(PBRefMenuItem *)sender;
Expand Down
10 changes: 10 additions & 0 deletions Classes/Controllers/PBRefController.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ - (void)awakeFromNib
[commitList registerForDraggedTypes:[NSArray arrayWithObject:@"PBGitRef"]];
}

#pragma mark Prune

- (void) pruneRemote:(PBRefMenuItem *)sender
{
id <PBGitRefish> refish = [sender refish];
if ([refish refishType] == kGitXCommitType)
return;

[historyController.repository beginPruneRemoteForRef:refish];
}

#pragma mark Fetch

Expand Down
7 changes: 7 additions & 0 deletions Classes/Views/PBRefMenuItem.m
Original file line number Diff line number Diff line change
Expand Up @@ -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]];
{
Expand Down
1 change: 1 addition & 0 deletions Classes/git/PBGitRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 21 additions & 0 deletions Classes/git/PBGitRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down