File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -940,9 +940,24 @@ - (IBAction)revertSelectedCommit:(id)sender {
940
940
[self revertCommit: commit againstLocalBranch: self .repository.history.HEADBranch];
941
941
}
942
942
943
+ - (GCHistoryLocalBranch *)branchToDeleteForSelectedCommit : (GCHistoryCommit *)commit {
944
+ NSArray <GCHistoryLocalBranch *>* localBranches = commit.localBranches ;
945
+ NSString *headBranchName = self.repository .history .HEADBranch .name ;
946
+
947
+ NSInteger index = [localBranches indexOfObjectPassingTest: ^BOOL (GCHistoryLocalBranch * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
948
+ return ![headBranchName isEqualToString: obj.name];
949
+ }];
950
+
951
+ if (index == NSNotFound ) {
952
+ return localBranches.firstObject ;
953
+ }
954
+
955
+ return localBranches[index];
956
+ }
957
+
943
958
- (IBAction )deleteSelectedCommit : (id )sender {
944
959
GCHistoryCommit* commit = _graphView.selectedCommit ;
945
- GCHistoryLocalBranch* localBranch = commit. localBranches . firstObject ;
960
+ GCHistoryLocalBranch* localBranch = [ self branchToDeleteForSelectedCommit: commit] ;
946
961
if (localBranch) {
947
962
NSAlert * alert = [[NSAlert alloc ] init ];
948
963
alert.messageText = NSLocalizedString(@" Do you want to delete the commit or the local branch?" , nil );
You can’t perform that action at this time.
0 commit comments