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

Add Copy Name menu item for branches #1009

Merged
merged 1 commit into from
Jun 29, 2024
Merged
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
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