Chris2011 commented on code in PR #8650:
URL: https://github.com/apache/netbeans/pull/8650#discussion_r2225319827


##########
ide/git/src/org/netbeans/modules/git/ui/branch/DeleteBranchAction.java:
##########
@@ -47,26 +52,47 @@ public class DeleteBranchAction extends 
SingleRepositoryAction {
     private static final Logger LOG = 
Logger.getLogger(DeleteBranchAction.class.getName());
 
     @Override
-    protected void performAction (File repository, File[] roots, VCSContext 
context) {
-        throw new UnsupportedOperationException();
+    protected void performAction(File repository, File[] roots, VCSContext 
context) {
+        RepositoryInfo info = RepositoryInfo.getInstance(repository);
+        HashMap<String, GitBranch> branches = new 
HashMap<>(info.getBranches());
+        branches.remove(info.getActiveBranch().getName());
+
+        if (branches.isEmpty()) {
+            return;
+        }
+
+        BranchSelector selector = new BranchSelector(repository, branches);
+        if (selector.open()) {
+            deleteBranch(repository, selector.getSelectedBranch());
+        }
+    }
+
+    @Override
+    protected boolean enable(Node[] activatedNodes) {
+        Map.Entry<File, File[]> actionRoots = 
getActionRoots(getCurrentContext(activatedNodes));
+        if (actionRoots != null) {
+            RepositoryInfo info = 
RepositoryInfo.getInstance(actionRoots.getKey());
+            return info.getBranches().size() > 1 && 
super.enable(activatedNodes);
+        }
+        return false;
     }

Review Comment:
   Done, thx for your help.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to