mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
Add Copy SHA and Copy Patch items to commit contextual menu
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
}
|
||||
|
||||
- (void) createBranch:(PBRefMenuItem *)sender;
|
||||
- (void) copySHA:(PBRefMenuItem *)sender;
|
||||
- (void) copyPatch:(PBRefMenuItem *)sender;
|
||||
|
||||
- (NSArray *) menuItemsForRef:(PBGitRef *)ref;
|
||||
- (NSArray *) menuItemsForCommit:(PBGitCommit *)commit;
|
||||
|
||||
@@ -46,6 +46,35 @@
|
||||
}
|
||||
|
||||
|
||||
#pragma mark Copy info
|
||||
|
||||
- (void) copySHA:(PBRefMenuItem *)sender
|
||||
{
|
||||
PBGitCommit *commit = nil;
|
||||
if ([[sender refish] refishType] == kGitXCommitType)
|
||||
commit = (PBGitCommit *)[sender refish];
|
||||
else
|
||||
commit = [historyController.repository commitForRef:[sender refish]];
|
||||
|
||||
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
|
||||
[pasteboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
|
||||
[pasteboard setString:[commit realSha] forType:NSStringPboardType];
|
||||
}
|
||||
|
||||
- (void) copyPatch:(PBRefMenuItem *)sender
|
||||
{
|
||||
PBGitCommit *commit = nil;
|
||||
if ([[sender refish] refishType] == kGitXCommitType)
|
||||
commit = (PBGitCommit *)[sender refish];
|
||||
else
|
||||
commit = [historyController.repository commitForRef:[sender refish]];
|
||||
|
||||
NSPasteboard *pasteboard = [NSPasteboard generalPasteboard];
|
||||
[pasteboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
|
||||
[pasteboard setString:[commit patch] forType:NSStringPboardType];
|
||||
}
|
||||
|
||||
|
||||
- (void) removeRefSheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
|
||||
{
|
||||
if (returnCode == NSAlertDefaultReturn) {
|
||||
|
||||
@@ -74,6 +74,10 @@
|
||||
NSMutableArray *items = [NSMutableArray array];
|
||||
|
||||
[items addObject:[PBRefMenuItem itemWithTitle:@"Create Branch…" action:@selector(createBranch:) enabled:YES]];
|
||||
[items addObject:[PBRefMenuItem separatorItem]];
|
||||
|
||||
[items addObject:[PBRefMenuItem itemWithTitle:@"Copy SHA" action:@selector(copySHA:) enabled:YES]];
|
||||
[items addObject:[PBRefMenuItem itemWithTitle:@"Copy Patch" action:@selector(copyPatch:) enabled:YES]];
|
||||
|
||||
for (PBRefMenuItem *item in items) {
|
||||
[item setTarget:target];
|
||||
|
||||
Reference in New Issue
Block a user