Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit a6c5049

Browse files
authored
Merge pull request #4 from github-for-unity/ui/delete-branch
Add a UI for deleting a branch
2 parents e3c2d72 + 7e15eb4 commit a6c5049

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/BranchesView.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,23 @@ private void OnCreateGUI()
440440
// Create button
441441
if (mode == BranchesMode.Default)
442442
{
443+
// If the current branch is selected, then do not enable the Delete button
444+
var disableDelete = activeBranchNode == selectedNode;
445+
EditorGUI.BeginDisabledGroup(disableDelete);
446+
{
447+
if (GUILayout.Button("Delete", EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
448+
{
449+
var selectedBranchName = selectedNode.Name;
450+
var dialogTitle = "Delete Branch: " + selectedBranchName;
451+
var dialogMessage = "Are you sure you want to delete the branch: " + selectedBranchName + "?";
452+
if (EditorUtility.DisplayDialog("Delete Branch?", dialogMessage, "Delete", "Cancel"))
453+
{
454+
GitClient.DeleteBranch(selectedBranchName, true).Start();
455+
}
456+
}
457+
}
458+
EditorGUI.EndDisabledGroup();
459+
443460
GUILayout.FlexibleSpace();
444461
if (GUILayout.Button(CreateBranchButton, EditorStyles.miniButton, GUILayout.ExpandWidth(false)))
445462
{

0 commit comments

Comments
 (0)