Skip to content

Commit 0921c6a

Browse files
author
Tim Hutt
committed
Checkout a branch when it is double-clicked in the sidebar
1 parent f8a6ba7 commit 0921c6a

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

Classes/Controllers/PBGitSidebarController.m

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -258,12 +258,22 @@ - (void)outlineViewSelectionDidChange:(NSNotification *)notification
258258
}
259259

260260
- (void)doubleClicked:(id)object {
261-
NSInteger rowNumber = [sourceView selectedRow];
262-
if ([[sourceView itemAtRow:rowNumber] isKindOfClass:[PBGitSVSubmoduleItem class]]) {
263-
PBGitSVSubmoduleItem *subModule = [sourceView itemAtRow:rowNumber];
264-
265-
[self openSubmoduleAtURL:[subModule path]];
266-
}
261+
NSInteger rowNumber = [sourceView selectedRow];
262+
263+
id item = [sourceView itemAtRow:rowNumber];
264+
if ([item isKindOfClass:[PBGitSVSubmoduleItem class]]) {
265+
PBGitSVSubmoduleItem *subModule = item;
266+
267+
[self openSubmoduleAtURL:[subModule path]];
268+
} else if ([item isKindOfClass:[PBGitSVBranchItem class]]) {
269+
PBGitSVBranchItem *branch = item;
270+
271+
NSError *error = nil;
272+
BOOL success = [repository checkoutRefish:[branch ref] error:&error];
273+
if (!success) {
274+
[self.windowController showErrorSheet:error];
275+
}
276+
}
267277
}
268278

269279
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item

0 commit comments

Comments
 (0)