27
27
#import " PBGitStash.h"
28
28
#import " PBGitSubmodule.h"
29
29
30
- #define kDialogDeleteRemoteBranch @" Delete Remote Branch"
31
- #define kDialogDeleteRemoteTag @" Delete Remote Tag"
32
-
33
30
34
31
NSString * PBGitRepositoryErrorDomain = @" GitXErrorDomain" ;
35
32
36
- @interface PBGitRepository ()
37
- - (void )checkDeleteRemoteBranch : (PBGitRef *)ref ;
38
- - (void )checkDeleteRemoteTag : (PBGitRef *)ref ;
39
- @end
40
-
41
33
dispatch_queue_t PBGetWorkQueue () {
42
34
#if 1
43
35
static dispatch_queue_t work_queue;
@@ -1356,114 +1348,28 @@ - (BOOL) deleteRemote:(PBGitRef *)ref
1356
1348
}
1357
1349
1358
1350
1359
- - (void )checkDeleteRemoteBranch : (PBGitRef *)ref
1360
- {
1361
- if ((!ref) || (![ref isRemoteBranch ]) )
1362
- {
1363
- return ;
1364
- }
1365
-
1366
- if (![self isRemoteConnected: ref])
1367
- {
1368
- NSString *info = [NSString stringWithFormat: @" Remote %@ is not conneted!" ,[ref remoteName ]];
1369
- NSError *error = [NSError errorWithDomain: PBGitRepositoryErrorDomain
1370
- code: 0
1371
- userInfo: [NSDictionary dictionaryWithObjectsAndKeys:
1372
- [NSString stringWithFormat: @" Can't remove the branch %@ from the remote %@ " ,[ref remoteBranchName ],[ref remoteName ]], NSLocalizedDescriptionKey ,
1373
- info, NSLocalizedRecoverySuggestionErrorKey ,
1374
- nil ]
1375
- ];
1376
- [[NSAlert alertWithError: error]runModal];
1377
- return ;
1378
- }
1379
-
1380
- if ([PBGitDefaults isDialogWarningSuppressedForDialog: kDialogDeleteRemoteBranch ]) {
1381
- [self deleteRemoteBranch: ref];
1382
- return ;
1383
- }
1384
-
1385
- NSAlert *alert = [NSAlert alertWithMessageText: [NSString stringWithFormat: @" Delete remotebranch %@ also on remote %@ ?" ,[ref remoteBranchName ],[ref remoteName ] ]
1386
- defaultButton: @" Delete"
1387
- alternateButton: @" Cancel"
1388
- otherButton: nil
1389
- informativeTextWithFormat: @" Are you sure you want to remove the remotebranch %@ also on remote %@ ?" ,[ref remoteBranchName ],[ref remoteName ]];
1390
- [alert setShowsSuppressionButton: YES ];
1391
-
1392
- [alert beginSheetModalForWindow: [[self windowController ] window ]
1393
- modalDelegate: self
1394
- didEndSelector: @selector (checkDeleteRemoteBranchSheetDidEnd:returnCode:contextInfo: )
1395
- contextInfo: Nil ];
1396
- actRef = ref;
1397
- }
1398
-
1399
-
1400
- - (void )checkDeleteRemoteBranchSheetDidEnd : (NSAlert *)sheet returnCode : (int )returnCode contextInfo : (void *)contextInfo
1401
- {
1402
- [[sheet window ] orderOut: nil ];
1403
-
1404
- if ([[sheet suppressionButton ] state ] == NSOnState )
1405
- [PBGitDefaults suppressDialogWarningForDialog: kDialogDeleteRemoteBranch ];
1406
-
1407
- if (returnCode == NSAlertDefaultReturn ) {
1408
- [self deleteRemoteBranch: actRef];
1409
- }
1410
- }
1411
-
1412
-
1413
1351
- (BOOL ) deleteRemoteBranch : (PBGitRef *)ref
1414
1352
{
1415
1353
if ((!ref) || (![ref isRemoteBranch ]) )
1416
1354
{
1417
1355
return NO ;
1418
1356
}
1419
1357
1420
- NSArray *arguments = [NSArray arrayWithObjects: @" push" , [ref remoteName ], [NSString stringWithFormat: @" :%@ " ,[ref remoteBranchName ]], nil ];
1421
- NSString *description = [NSString stringWithFormat: @" Deleting Remotebranch %@ from remote %@ " ,[ref remoteBranchName ], [ref remoteName ]];
1422
- NSString *title = @" Deleting Branch from remote" ;
1423
- [PBRemoteProgressSheet beginRemoteProgressSheetForArguments: arguments title: title description: description inRepository: self ];
1358
+ int alertRet = [[NSAlert alertWithMessageText: [NSString stringWithFormat: @" Delete branch %@ on remote %@ ?" ,[ref remoteBranchName ],[ref remoteName ]]
1359
+ defaultButton: @" Yes"
1360
+ alternateButton: @" No"
1361
+ otherButton: nil
1362
+ informativeTextWithFormat: [NSString stringWithFormat: @" Delete branch %@ on remote %@ ?" ,[ref remoteBranchName ],[ref remoteName ]]]
1363
+ runModal ];
1424
1364
1425
- [self reloadRefs ];
1426
- return YES ;
1427
- }
1428
-
1429
-
1430
- - (void )checkDeleteRemoteTag : (PBGitRef *)ref
1431
- {
1432
- if ((!ref) || (![ref isTag ]) || (![self hasRemotes ]) )
1365
+ if (alertRet == NSAlertDefaultReturn )
1433
1366
{
1434
- return ;
1367
+ NSArray *arguments = [NSArray arrayWithObjects: @" push" , [ref remoteName ], [NSString stringWithFormat: @" :%@ " ,[ref remoteBranchName ]], nil ];
1368
+ NSString *description = [NSString stringWithFormat: @" Deleting Remotebranch %@ from remote %@ " ,[ref remoteBranchName ], [ref remoteName ]];
1369
+ NSString *title = @" Deleting Branch from remote" ;
1370
+ [PBRemoteProgressSheet beginRemoteProgressSheetForArguments: arguments title: title description: description inRepository: self ];
1435
1371
}
1436
-
1437
- if ([PBGitDefaults isDialogWarningSuppressedForDialog: kDialogDeleteRemoteTag ]) {
1438
- [self deleteRemoteTag: ref];
1439
- return ;
1440
- }
1441
-
1442
- NSAlert *alert = [NSAlert alertWithMessageText: [NSString stringWithFormat: @" Delete tag %@ also on remotes where exists?" ,[ref tagName ]]
1443
- defaultButton: @" Delete"
1444
- alternateButton: @" Cancel"
1445
- otherButton: nil
1446
- informativeTextWithFormat: @" Are you sure you want to remove the tag %@ also on remotes where the tag exists?" ,[ref tagName ]];
1447
- [alert setShowsSuppressionButton: YES ];
1448
-
1449
- [alert beginSheetModalForWindow: [[self windowController ] window ]
1450
- modalDelegate: self
1451
- didEndSelector: @selector (checkDeleteRemoteTagSheetDidEnd:returnCode:contextInfo: )
1452
- contextInfo: Nil ];
1453
- actRef = ref;
1454
- }
1455
-
1456
-
1457
- - (void )checkDeleteRemoteTagSheetDidEnd : (NSAlert *)sheet returnCode : (int )returnCode contextInfo : (void *)contextInfo
1458
- {
1459
- [[sheet window ] orderOut: nil ];
1460
-
1461
- if ([[sheet suppressionButton ] state ] == NSOnState )
1462
- [PBGitDefaults suppressDialogWarningForDialog: kDialogDeleteRemoteTag ];
1463
-
1464
- if (returnCode == NSAlertDefaultReturn ) {
1465
- [self deleteRemoteTag: actRef];
1466
- }
1372
+ return YES ;
1467
1373
}
1468
1374
1469
1375
@@ -1526,15 +1432,18 @@ - (BOOL) deleteRemoteTag:(PBGitRef *)ref
1526
1432
informativeTextWithFormat: [NSString stringWithFormat: @" %@ \n\n %@ " ,argumentsString,output]
1527
1433
] runModal ];
1528
1434
}
1435
+
1436
+ [self reloadRefs ];
1437
+
1529
1438
}
1530
1439
}
1531
1440
}
1532
1441
}
1533
1442
1534
- [self reloadRefs ];
1535
1443
return YES ;
1536
1444
}
1537
1445
1446
+
1538
1447
- (BOOL ) deleteRef : (PBGitRef *)ref
1539
1448
{
1540
1449
if (!ref)
@@ -1546,21 +1455,21 @@ - (BOOL) deleteRef:(PBGitRef *)ref
1546
1455
}
1547
1456
else if ([ref refishType ] == kGitXRemoteBranchType )
1548
1457
{
1549
- [self checkDeleteRemoteBranch : ref];
1458
+ [self deleteRemoteBranch : ref];
1550
1459
}
1551
1460
else if ([ref refishType ] == kGitXTagType )
1552
1461
{
1553
1462
if ([self refExistsOnAnyRemote: ref])
1554
1463
{
1555
- [self checkDeleteRemoteTag : ref];
1464
+ [self deleteRemoteTag : ref];
1556
1465
}
1557
1466
}
1558
1467
1559
1468
int retValue = 1 ;
1560
1469
NSArray *arguments = [NSArray arrayWithObjects: @" update-ref" , @" -d" , [ref ref ], nil ];
1561
1470
NSString * output = [self outputForArguments: arguments retValue: &retValue];
1562
1471
if (retValue) {
1563
- NSString *message = [NSString stringWithFormat: @" There was an error deleting the ref: %@ \n\n " , [ref shortName ]];
1472
+ NSString *message = [NSString stringWithFormat: @" There was an error deleting the %@ %@ \n\n " , [ref refishType ] , [ref shortName ]];
1564
1473
[self .windowController showErrorSheetTitle: @" Delete ref failed!" message: message arguments: arguments output: output];
1565
1474
return NO ;
1566
1475
}
0 commit comments