Skip to content

Commit

Permalink
Add Copy Name menu item for branches (#1009)
Browse files Browse the repository at this point in the history
Fixes #1008
  • Loading branch information
lucasderraugh authored Jun 29, 2024
1 parent b7a1da7 commit 9cae310
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions GitUpKit/Views/GIMapViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,10 @@ - (NSMenu*)graphView:(GIGraphView*)graphView willShowContextualMenuForNode:(GINo
for (GCHistoryLocalBranch* branch in node.commit.localBranches) {
GCBranch* upstream = branch.upstream;
NSMenu* menu = [[NSMenu alloc] init];

item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Copy Name", nil) action:@selector(_copyBranchName:) keyEquivalent:@""];
item.representedObject = branch;
[menu addItem:item];

item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Rename…", nil) action:@selector(_renameLocalBranch:) keyEquivalent:@""];
item.representedObject = branch;
Expand Down Expand Up @@ -420,6 +424,11 @@ - (NSMenu*)graphView:(GIGraphView*)graphView willShowContextualMenuForNode:(GINo
break;
}
}

item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Copy Name", nil) action:@selector(_copyBranchName:) keyEquivalent:@""];
item.representedObject = branch;
[menu addItem:item];

if (!found) {
item = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Checkout New Tracking Local Branch", nil) action:@selector(_checkoutRemoteBranch:) keyEquivalent:@""];
item.representedObject = branch;
Expand Down Expand Up @@ -1109,6 +1118,13 @@ - (IBAction)_renameLocalBranch:(id)sender {
}];
}

- (IBAction)_copyBranchName:(id)sender {
GCBranch* branch = [(NSMenuItem*)sender representedObject];
NSPasteboard* pasteboard = NSPasteboard.generalPasteboard;
[pasteboard clearContents];
[pasteboard setString:branch.name forType:NSPasteboardTypeString];
}

- (IBAction)_deleteLocalBranch:(id)sender {
GCHistoryLocalBranch* branch = [(NSMenuItem*)sender representedObject];
[self deleteLocalBranch:branch];
Expand Down

0 comments on commit 9cae310

Please sign in to comment.