@@ -943,6 +943,25 @@ public void AbortMerge()
943943 _workingCopy ? . AbortMerge ( ) ;
944944 }
945945
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+
946965 public void RefreshBranches ( )
947966 {
948967 var branches = new Commands . QueryBranches ( _fullpath ) . Result ( ) ;
@@ -1443,22 +1462,10 @@ public ContextMenu CreateContextMenuForGitLFS()
14431462
14441463 public ContextMenu CreateContextMenuForCustomAction ( )
14451464 {
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-
14591465 var menu = new ContextMenu ( ) ;
14601466 menu . Placement = PlacementMode . BottomEdgeAlignedLeft ;
14611467
1468+ var actions = GetCustomActions ( Models . CustomActionScope . Repository ) ;
14621469 if ( actions . Count > 0 )
14631470 {
14641471 foreach ( var action in actions )
@@ -2355,19 +2362,7 @@ private BranchTreeNode FindBranchNode(List<BranchTreeNode> nodes, string path)
23552362
23562363 private void TryToAddCustomActionsToBranchContextMenu ( ContextMenu menu , Models . Branch branch )
23572364 {
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 ) ;
23712366 if ( actions . Count == 0 )
23722367 return ;
23732368
0 commit comments