Skip to content

Commit 6a1a340

Browse files
lolgearlucasderraugh
authored andcommitted
MapView: Copy commit message action (#577)
* kit: mapview copy commit message operation has been added. * kit: mapview contextual menu entry copy selected commit message has been added. * kit: copy selected commit message typo has been fixed. * kit: views map view pasteboard declare types invocation has been added. * kit: views map view contextual menu entry has been renamed.
1 parent e2d4dd4 commit 6a1a340

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

GitUpKit/Views/Base.lproj/GIMapViewController.xib

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ DQ
111111
<action selector="editSelectedCommitMessage:" target="-2" id="PrK-v7-e6I"/>
112112
</connections>
113113
</menuItem>
114+
<menuItem title="Copy Message" alternate="YES" keyEquivalent="e" id="LnA-LI-dEb">
115+
<modifierMask key="keyEquivalentModifierMask" option="YES"/>
116+
<connections>
117+
<action selector="copySelectedCommitMessage:" target="-2" id="dDP-sd-Fqm"/>
118+
</connections>
119+
</menuItem>
114120
<menuItem title="Fixup with Parent" keyEquivalent="f" id="ss5-jL-Qe5">
115121
<modifierMask key="keyEquivalentModifierMask"/>
116122
<connections>
@@ -251,10 +257,10 @@ CA
251257
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
252258
<clipView key="contentView" drawsBackground="NO" id="K5e-oW-uzS">
253259
<rect key="frame" x="1" y="1" width="278" height="58"/>
254-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
260+
<autoresizingMask key="autoresizingMask"/>
255261
<subviews>
256262
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" findStyle="panel" allowsUndo="YES" smartInsertDelete="YES" id="l0i-wG-st7" customClass="GICommitMessageView">
257-
<rect key="frame" x="0.0" y="75" width="278" height="58"/>
263+
<rect key="frame" x="0.0" y="75" width="293" height="58"/>
258264
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
259265
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
260266
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@@ -446,7 +452,7 @@ Gw
446452
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
447453
<clipView key="contentView" drawsBackground="NO" id="THQ-ht-MMy">
448454
<rect key="frame" x="1" y="1" width="548" height="148"/>
449-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
455+
<autoresizingMask key="autoresizingMask"/>
450456
<subviews>
451457
<textView importsGraphics="NO" richText="NO" verticallyResizable="YES" findStyle="panel" allowsUndo="YES" smartInsertDelete="YES" id="leL-YY-uqs" customClass="GICommitMessageView">
452458
<rect key="frame" x="0.0" y="0.0" width="548" height="148"/>

GitUpKit/Views/GIMapViewController+Operations.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
- (void)cherryPickCommit:(GCHistoryCommit*)commit againstLocalBranch:(GCHistoryLocalBranch*)branch;
3434
- (void)revertCommit:(GCHistoryCommit*)commit againstLocalBranch:(GCHistoryLocalBranch*)branch;
3535
- (void)editCommitMessage:(GCHistoryCommit*)commit;
36+
- (void)copyCommitMessage:(GCHistoryCommit*)commit;
3637

3738
- (void)createLocalBranchAtCommit:(GCHistoryCommit*)commit withName:(NSString*)name checkOut:(BOOL)checkOut;
3839
- (void)deleteLocalBranch:(GCHistoryLocalBranch*)branch;

GitUpKit/Views/GIMapViewController+Operations.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,13 @@ - (void)editCommitMessage:(GCHistoryCommit*)commit {
395395
}];
396396
}
397397

398+
- (void)copyCommitMessage:(GCHistoryCommit*)commit {
399+
NSString* message = _CleanedUpCommitMessage(commit.message);
400+
[self.windowController showOverlayWithStyle:kGIOverlayStyle_Informational format:NSLocalizedString(@"Commit message copied: \"%@\"", nil), message];
401+
[[NSPasteboard generalPasteboard] declareTypes:@[NSStringPboardType] owner:nil];
402+
[[NSPasteboard generalPasteboard] setString:message forType:NSPasteboardTypeString];
403+
}
404+
398405
#pragma mark - Local Branches
399406

400407
// This will abort on conflicts in workdir or index so there's no need to require a clean repo

GitUpKit/Views/GIMapViewController.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,11 @@ - (IBAction)editSelectedCommitMessage:(id)sender {
916916
[self editCommitMessage:commit];
917917
}
918918

919+
- (IBAction)copySelectedCommitMessage:(id)sender {
920+
GCHistoryCommit* commit = self.graphView.selectedNode.commit;
921+
[self copyCommitMessage:commit];
922+
}
923+
919924
- (IBAction)rewriteSelectedCommit:(id)sender {
920925
GCHistoryCommit* commit = self.graphView.selectedNode.commit;
921926
if ([self checkCleanRepositoryForOperationOnCommit:commit]) {

0 commit comments

Comments
 (0)