This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new b278014c2d some extra code hardening on git branches, fixes #5497 
(#5835)
b278014c2d is described below

commit b278014c2d2e80f7196536af99402dae86f3123a
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Wed Oct 15 18:15:50 2025 +0200

    some extra code hardening on git branches, fixes #5497 (#5835)
---
 .../main/java/org/apache/hop/git/GitGuiPlugin.java | 261 +++++++++++----------
 .../hop/git/messages/messages_en_US.properties     |   2 +
 2 files changed, 138 insertions(+), 125 deletions(-)

diff --git 
a/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java 
b/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java
index 8955b983ee..0bf8e8fd11 100644
--- a/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java
+++ b/plugins/misc/git/src/main/java/org/apache/hop/git/GitGuiPlugin.java
@@ -301,145 +301,156 @@ public class GitGuiPlugin
       label = "xxxxxxxxxxxxxxxxxxxxx",
       toolTip = "i18n::GitGuiPlugin.Toolbar.Branch.Tooltip")
   public void gitBranches() {
-    List<String> branches = git.getBranches();
-    Menu menu = new Menu(HopGui.getInstance().getShell());
-    String currentBranch = git.getBranch();
-
-    MenuItem createBranch = new MenuItem(menu, SWT.PUSH);
-    createBranch.setText(BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.CreateBranch"));
-    MenuItem deleteBranch = new MenuItem(menu, SWT.PUSH);
-    deleteBranch.setText(BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.DeleteBranch"));
-    MenuItem mergeBranch = new MenuItem(menu, SWT.PUSH);
-    mergeBranch.setText(BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.MergeBranch"));
-    new MenuItem(menu, SWT.SEPARATOR);
-
-    // Create Branch listener
-    createBranch.addSelectionListener(
-        new SelectionAdapter() {
-          @Override
-          public void widgetSelected(SelectionEvent e) {
-            EnterStringDialog enterStringDialog =
-                new EnterStringDialog(
-                    HopGui.getInstance().getShell(),
-                    "",
-                    BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.CreateBranch.Header"),
-                    BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.CreateBranch.Message"));
-            String message = enterStringDialog.open();
-            if (message != null) {
-              boolean branchCreated = git.createBranch(message);
-              if (branchCreated) {
-                MessageBox pullSuccessful =
-                    new MessageBox(HopGui.getInstance().getShell(), 
SWT.ICON_INFORMATION);
-                pullSuccessful.setText(
-                    BaseMessages.getString(
-                        PKG, 
"GitGuiPlugin.Dialog.Branch.CreateBranchSuccessFul.Header"));
-                pullSuccessful.setMessage(
-                    BaseMessages.getString(
-                        PKG, 
"GitGuiPlugin.Dialog.Branch.CreateBranchSuccessFul.Message"));
-                pullSuccessful.open();
-              }
-              // Refresh the tree, change colors...
-              //
-              ExplorerPerspective.getInstance().refresh();
-            }
-          }
-        });
-
-    // Delete Branch listener
-    deleteBranch.addSelectionListener(
-        new SelectionAdapter() {
-          @Override
-          public void widgetSelected(SelectionEvent e) {
-            EnterSelectionDialog selectionDialog =
-                new EnterSelectionDialog(
-                    HopGui.getInstance().getShell(),
-                    branches.toArray(new String[0]),
-                    BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.DeleteBranch.Header"),
-                    BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.DeleteBranch.Message"));
-            String branchToDelete = selectionDialog.open();
-            if (branchToDelete != null) {
-              boolean branchDeleted = git.deleteBranch(branchToDelete, true);
-              if (branchDeleted) {
-                MessageBox pullSuccessful =
-                    new MessageBox(HopGui.getInstance().getShell(), 
SWT.ICON_INFORMATION);
-                pullSuccessful.setText(
-                    BaseMessages.getString(
-                        PKG, 
"GitGuiPlugin.Dialog.Branch.DeleteBranchSuccessFul.Header"));
-                pullSuccessful.setMessage(
-                    BaseMessages.getString(
-                        PKG, 
"GitGuiPlugin.Dialog.Branch.DeleteBranchSuccessFul.Message"));
-                pullSuccessful.open();
+    try {
+      List<String> branches = git.getBranches();
+      Menu menu = new Menu(HopGui.getInstance().getShell());
+      String currentBranch = git.getBranch();
+
+      MenuItem createBranch = new MenuItem(menu, SWT.PUSH);
+      createBranch.setText(BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.CreateBranch"));
+      MenuItem deleteBranch = new MenuItem(menu, SWT.PUSH);
+      deleteBranch.setText(BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.DeleteBranch"));
+      MenuItem mergeBranch = new MenuItem(menu, SWT.PUSH);
+      mergeBranch.setText(BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.MergeBranch"));
+      new MenuItem(menu, SWT.SEPARATOR);
+
+      // Create Branch listener
+      createBranch.addSelectionListener(
+          new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+              EnterStringDialog enterStringDialog =
+                  new EnterStringDialog(
+                      HopGui.getInstance().getShell(),
+                      "",
+                      BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.CreateBranch.Header"),
+                      BaseMessages.getString(
+                          PKG, 
"GitGuiPlugin.Dialog.Branch.CreateBranch.Message"));
+              String message = enterStringDialog.open();
+              if (message != null) {
+                boolean branchCreated = git.createBranch(message);
+                if (branchCreated) {
+                  MessageBox pullSuccessful =
+                      new MessageBox(HopGui.getInstance().getShell(), 
SWT.ICON_INFORMATION);
+                  pullSuccessful.setText(
+                      BaseMessages.getString(
+                          PKG, 
"GitGuiPlugin.Dialog.Branch.CreateBranchSuccessFul.Header"));
+                  pullSuccessful.setMessage(
+                      BaseMessages.getString(
+                          PKG, 
"GitGuiPlugin.Dialog.Branch.CreateBranchSuccessFul.Message"));
+                  pullSuccessful.open();
+                }
+                // Refresh the tree, change colors...
+                //
+                ExplorerPerspective.getInstance().refresh();
               }
-              // Refresh the tree, change colors...
-              //
-              ExplorerPerspective.getInstance().refresh();
             }
-          }
-        });
-
-    // Merge Branch listener
-    mergeBranch.addSelectionListener(
-        new SelectionAdapter() {
-          @Override
-          public void widgetSelected(SelectionEvent e) {
-            EnterSelectionDialog selectionDialog =
-                new EnterSelectionDialog(
-                    HopGui.getInstance().getShell(),
-                    branches.toArray(new String[0]),
-                    BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.MergeBranch.Header"),
-                    BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.MergeBranch.Message"));
-            String branchToMerge = selectionDialog.open();
-            if (branchToMerge != null) {
-              try {
-                boolean branchMerged = git.mergeBranch(branchToMerge, 
MergeStrategy.RECURSIVE);
-                if (branchMerged) {
-                  MessageBox mergeSuccessful =
+          });
+
+      // Delete Branch listener
+      deleteBranch.addSelectionListener(
+          new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+              EnterSelectionDialog selectionDialog =
+                  new EnterSelectionDialog(
+                      HopGui.getInstance().getShell(),
+                      branches.toArray(new String[0]),
+                      BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.DeleteBranch.Header"),
+                      BaseMessages.getString(
+                          PKG, 
"GitGuiPlugin.Dialog.Branch.DeleteBranch.Message"));
+              String branchToDelete = selectionDialog.open();
+              if (branchToDelete != null) {
+                boolean branchDeleted = git.deleteBranch(branchToDelete, true);
+                if (branchDeleted) {
+                  MessageBox pullSuccessful =
                       new MessageBox(HopGui.getInstance().getShell(), 
SWT.ICON_INFORMATION);
-                  mergeSuccessful.setText(
+                  pullSuccessful.setText(
                       BaseMessages.getString(
-                          PKG, 
"GitGuiPlugin.Dialog.Branch.MergeBranchSuccessFul.Header"));
-                  mergeSuccessful.setMessage(
+                          PKG, 
"GitGuiPlugin.Dialog.Branch.DeleteBranchSuccessFul.Header"));
+                  pullSuccessful.setMessage(
                       BaseMessages.getString(
-                          PKG, 
"GitGuiPlugin.Dialog.Branch.MergeBranchSuccessFul.Message"));
-                  mergeSuccessful.open();
+                          PKG, 
"GitGuiPlugin.Dialog.Branch.DeleteBranchSuccessFul.Message"));
+                  pullSuccessful.open();
                 }
-              } catch (Exception ex) {
-                new ErrorDialog(
-                    HopGui.getInstance().getShell(),
-                    BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.MergeBranchError.Header"),
-                    BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.MergeBranchError.Message"),
-                    ex);
+                // Refresh the tree, change colors...
+                //
+                ExplorerPerspective.getInstance().refresh();
               }
-              // Refresh the tree, change colors...
-              //
-              ExplorerPerspective.getInstance().refresh();
             }
-          }
-        });
-
-    // Add all known branches to the list
-    for (String branch : branches) {
-      MenuItem item = new MenuItem(menu, SWT.CHECK);
-      item.setText(branch);
-      // If the item is the active branch mark it as checked
-      if (branch.equals(currentBranch)) {
-        item.setSelection(true);
-      }
-      // Change Branch when selecting one of the branch options
-      item.addSelectionListener(
+          });
+
+      // Merge Branch listener
+      mergeBranch.addSelectionListener(
           new SelectionAdapter() {
             @Override
             public void widgetSelected(SelectionEvent e) {
-              MenuItem item = (MenuItem) e.widget;
-              git.checkout(item.getText());
-              // Refresh the tree, change colors...
-              //
-              ExplorerPerspective.getInstance().refresh();
+              EnterSelectionDialog selectionDialog =
+                  new EnterSelectionDialog(
+                      HopGui.getInstance().getShell(),
+                      branches.toArray(new String[0]),
+                      BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.Branch.MergeBranch.Header"),
+                      BaseMessages.getString(
+                          PKG, 
"GitGuiPlugin.Dialog.Branch.MergeBranch.Message"));
+              String branchToMerge = selectionDialog.open();
+              if (branchToMerge != null) {
+                try {
+                  boolean branchMerged = git.mergeBranch(branchToMerge, 
MergeStrategy.RECURSIVE);
+                  if (branchMerged) {
+                    MessageBox mergeSuccessful =
+                        new MessageBox(HopGui.getInstance().getShell(), 
SWT.ICON_INFORMATION);
+                    mergeSuccessful.setText(
+                        BaseMessages.getString(
+                            PKG, 
"GitGuiPlugin.Dialog.Branch.MergeBranchSuccessFul.Header"));
+                    mergeSuccessful.setMessage(
+                        BaseMessages.getString(
+                            PKG, 
"GitGuiPlugin.Dialog.Branch.MergeBranchSuccessFul.Message"));
+                    mergeSuccessful.open();
+                  }
+                } catch (Exception ex) {
+                  new ErrorDialog(
+                      HopGui.getInstance().getShell(),
+                      BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.MergeBranchError.Header"),
+                      BaseMessages.getString(PKG, 
"GitGuiPlugin.Dialog.MergeBranchError.Message"),
+                      ex);
+                }
+                // Refresh the tree, change colors...
+                //
+                ExplorerPerspective.getInstance().refresh();
+              }
             }
           });
-    }
 
-    menu.setVisible(true);
+      // Add all known branches to the list
+      for (String branch : branches) {
+        MenuItem item = new MenuItem(menu, SWT.CHECK);
+        item.setText(branch);
+        // If the item is the active branch mark it as checked
+        if (branch.equals(currentBranch)) {
+          item.setSelection(true);
+        }
+        // Change Branch when selecting one of the branch options
+        item.addSelectionListener(
+            new SelectionAdapter() {
+              @Override
+              public void widgetSelected(SelectionEvent e) {
+                MenuItem item = (MenuItem) e.widget;
+                git.checkout(item.getText());
+                // Refresh the tree, change colors...
+                //
+                ExplorerPerspective.getInstance().refresh();
+              }
+            });
+      }
+
+      menu.setVisible(true);
+    } catch (Exception e) {
+      new ErrorDialog(
+          HopGui.getInstance().getShell(),
+          BaseMessages.getString(PKG, "GitGuiPlugin.Dialog.Branch.Header"),
+          BaseMessages.getString(PKG, "GitGuiPlugin.Dialog.Branch.Message"),
+          e);
+    }
   }
 
   @GuiMenuElement(
diff --git 
a/plugins/misc/git/src/main/resources/org/apache/hop/git/messages/messages_en_US.properties
 
b/plugins/misc/git/src/main/resources/org/apache/hop/git/messages/messages_en_US.properties
index 09eddb19a5..8a38e968b7 100644
--- 
a/plugins/misc/git/src/main/resources/org/apache/hop/git/messages/messages_en_US.properties
+++ 
b/plugins/misc/git/src/main/resources/org/apache/hop/git/messages/messages_en_US.properties
@@ -48,6 +48,8 @@ GitGuiPlugin.Dialog.NoFilesToRevert.Header=No Files to Revert
 GitGuiPlugin.Dialog.NoFilesToRevert.Message=Sorry, there are no files to revert
 GitGuiPlugin.Dialog.PullError.Header=GIT Pull Error
 GitGuiPlugin.Dialog.PullError.Message=There was an error doing a git pull
+GitGuiPlugin.Dialog.Branch.Header=GIT Branches error
+GitGuiPlugin.Dialog.Branch.Message=There was an listing and getting the 
branches
 GitGuiPlugin.Dialog.PullSuccessful.Header=Successful Pull
 GitGuiPlugin.Dialog.PullSuccessful.Message=Successful Pull
 GitGuiPlugin.Dialog.PushError.Header=GIT Push Error

Reply via email to