Skip to content

Commit 8133974

Browse files
authored
Merge pull request #135 from Timmmm/doubleclick_branches_checkout
Checkout a branch when it is double-clicked in the sidebar
2 parents 78e75b2 + 0921c6a commit 8133974

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
@@ -245,12 +245,22 @@ - (void)outlineViewSelectionDidChange:(NSNotification *)notification
245245
}
246246

247247
- (void)doubleClicked:(id)object {
248-
NSInteger rowNumber = [sourceView selectedRow];
249-
if ([[sourceView itemAtRow:rowNumber] isKindOfClass:[PBGitSVSubmoduleItem class]]) {
250-
PBGitSVSubmoduleItem *subModule = [sourceView itemAtRow:rowNumber];
251-
252-
[self openSubmoduleAtURL:[subModule path]];
253-
}
248+
NSInteger rowNumber = [sourceView selectedRow];
249+
250+
id item = [sourceView itemAtRow:rowNumber];
251+
if ([item isKindOfClass:[PBGitSVSubmoduleItem class]]) {
252+
PBGitSVSubmoduleItem *subModule = item;
253+
254+
[self openSubmoduleAtURL:[subModule path]];
255+
} else if ([item isKindOfClass:[PBGitSVBranchItem class]]) {
256+
PBGitSVBranchItem *branch = item;
257+
258+
NSError *error = nil;
259+
BOOL success = [repository checkoutRefish:[branch ref] error:&error];
260+
if (!success) {
261+
[self.windowController showErrorSheet:error];
262+
}
263+
}
254264
}
255265

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

0 commit comments

Comments
 (0)