@@ -943,6 +943,25 @@ public void AbortMerge()
943
943
_workingCopy ? . AbortMerge ( ) ;
944
944
}
945
945
946
+ public List < Models . CustomAction > GetCustomActions ( Models . CustomActionScope scope )
947
+ {
948
+ var actions = new List < Models . CustomAction > ( ) ;
949
+
950
+ foreach ( var act in Preferences . Instance . CustomActions )
951
+ {
952
+ if ( act . Scope == scope )
953
+ actions . Add ( act ) ;
954
+ }
955
+
956
+ foreach ( var act in _settings . CustomActions )
957
+ {
958
+ if ( act . Scope == scope )
959
+ actions . Add ( act ) ;
960
+ }
961
+
962
+ return actions ;
963
+ }
964
+
946
965
public void RefreshBranches ( )
947
966
{
948
967
var branches = new Commands . QueryBranches ( _fullpath ) . Result ( ) ;
@@ -1443,22 +1462,10 @@ public ContextMenu CreateContextMenuForGitLFS()
1443
1462
1444
1463
public ContextMenu CreateContextMenuForCustomAction ( )
1445
1464
{
1446
- var actions = new List < Models . CustomAction > ( ) ;
1447
- foreach ( var action in Preferences . Instance . CustomActions )
1448
- {
1449
- if ( action . Scope == Models . CustomActionScope . Repository )
1450
- actions . Add ( action ) ;
1451
- }
1452
-
1453
- foreach ( var action in _settings . CustomActions )
1454
- {
1455
- if ( action . Scope == Models . CustomActionScope . Repository )
1456
- actions . Add ( action ) ;
1457
- }
1458
-
1459
1465
var menu = new ContextMenu ( ) ;
1460
1466
menu . Placement = PlacementMode . BottomEdgeAlignedLeft ;
1461
1467
1468
+ var actions = GetCustomActions ( Models . CustomActionScope . Repository ) ;
1462
1469
if ( actions . Count > 0 )
1463
1470
{
1464
1471
foreach ( var action in actions )
@@ -2355,19 +2362,7 @@ private BranchTreeNode FindBranchNode(List<BranchTreeNode> nodes, string path)
2355
2362
2356
2363
private void TryToAddCustomActionsToBranchContextMenu ( ContextMenu menu , Models . Branch branch )
2357
2364
{
2358
- var actions = new List < Models . CustomAction > ( ) ;
2359
- foreach ( var action in Preferences . Instance . CustomActions )
2360
- {
2361
- if ( action . Scope == Models . CustomActionScope . Branch )
2362
- actions . Add ( action ) ;
2363
- }
2364
-
2365
- foreach ( var action in Settings . CustomActions )
2366
- {
2367
- if ( action . Scope == Models . CustomActionScope . Branch )
2368
- actions . Add ( action ) ;
2369
- }
2370
-
2365
+ var actions = GetCustomActions ( Models . CustomActionScope . Branch ) ;
2371
2366
if ( actions . Count == 0 )
2372
2367
return ;
2373
2368
0 commit comments