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

Commit a067e39

Browse files
Showing a dialog with the error when branch creation fails
1 parent e42062e commit a067e39

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using UnityEditor;
55
using UnityEngine;
6+
using Debug = System.Diagnostics.Debug;
67

78
namespace GitHub.Unity
89
{
@@ -17,6 +18,7 @@ class BranchesView : Subview
1718
private const string NewBranchConfirmButton = "Create";
1819
private const string FavoritesSetting = "Favorites";
1920
private const string FavoritesTitle = "Favorites";
21+
private const string CreateBranchTitle = "Create branch";
2022
private const string LocalTitle = "Local branches";
2123
private const string RemoteTitle = "Remote branches";
2224
private const string CreateBranchButton = "New Branch";
@@ -500,7 +502,21 @@ private void OnCreateGUI()
500502
if (createBranch)
501503
{
502504
GitClient.CreateBranch(newBranchName, selectedNode.Name)
503-
.FinallyInUI((success, e) => { if (success) Refresh(); })
505+
.FinallyInUI((success, e) => {
506+
if (success)
507+
{
508+
Refresh();
509+
}
510+
else
511+
{
512+
var errorHeader = "fatal: ";
513+
var errorMessage = e.Message.StartsWith(errorHeader) ? e.Message.Remove(0, errorHeader.Length) : e.Message;
514+
515+
EditorUtility.DisplayDialog(CreateBranchTitle,
516+
errorMessage,
517+
Localization.Cancel);
518+
}
519+
})
504520
.Start();
505521
}
506522

0 commit comments

Comments
 (0)