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

Commit 833feaa

Browse files
committed
Friendlier lock error message when permissions fail
1 parent 764df01 commit 833feaa

File tree

3 files changed

+63
-7
lines changed

3 files changed

+63
-7
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/Misc/Styles.cs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ class Styles
9292
selectedLabel,
9393
progressAreaBackStyle,
9494
labelNoWrap,
95-
invisibleLabel;
95+
invisibleLabel,
96+
locksViewLockedByStyle,
97+
locksViewLockedBySelectedStyle;
9698

9799
private static Texture2D branchIcon,
98100
activeBranchIcon,
@@ -633,6 +635,45 @@ public static GUIStyle HistoryDetailsMetaInfoStyle
633635
}
634636
}
635637

638+
public static GUIStyle LocksViewLockedByStyle
639+
{
640+
get
641+
{
642+
if (locksViewLockedByStyle == null)
643+
{
644+
locksViewLockedByStyle = new GUIStyle(EditorStyles.miniLabel);
645+
locksViewLockedByStyle.name = "LocksViewLockedByStyle";
646+
var hierarchyStyle = GUI.skin.FindStyle("PR Label");
647+
locksViewLockedByStyle.onNormal.background = hierarchyStyle.onNormal.background;
648+
locksViewLockedByStyle.onNormal.textColor = hierarchyStyle.onNormal.textColor;
649+
locksViewLockedByStyle.onFocused.background = hierarchyStyle.onFocused.background;
650+
locksViewLockedByStyle.onFocused.textColor = hierarchyStyle.onFocused.textColor;
651+
}
652+
return locksViewLockedByStyle;
653+
}
654+
}
655+
656+
public static GUIStyle LocksViewLockedBySelectedStyle
657+
{
658+
get
659+
{
660+
if (locksViewLockedBySelectedStyle == null)
661+
{
662+
locksViewLockedBySelectedStyle = new GUIStyle(EditorStyles.miniLabel);
663+
locksViewLockedBySelectedStyle.name = "LocksViewLockedBySelectedStyle";
664+
var hierarchyStyle = GUI.skin.FindStyle("PR Label");
665+
locksViewLockedBySelectedStyle.onNormal.textColor = hierarchyStyle.onNormal.textColor;
666+
locksViewLockedBySelectedStyle.onNormal.background = hierarchyStyle.onFocused.background;
667+
locksViewLockedBySelectedStyle.onNormal.textColor = hierarchyStyle.onNormal.textColor;
668+
locksViewLockedBySelectedStyle.onFocused.background = hierarchyStyle.onFocused.background;
669+
locksViewLockedBySelectedStyle.onFocused.textColor = hierarchyStyle.onNormal.textColor;
670+
locksViewLockedBySelectedStyle.normal.background = hierarchyStyle.onFocused.background;
671+
locksViewLockedBySelectedStyle.normal.textColor = hierarchyStyle.onNormal.textColor;
672+
}
673+
return locksViewLockedBySelectedStyle;
674+
}
675+
}
676+
636677
public static GUIStyle CommitFileAreaStyle
637678
{
638679
get

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private Rect RenderEntry(Rect entryRect, GitLockEntry entry)
150150
}
151151
GUILayout.BeginVertical();
152152
GUILayout.Label(entry.GitLock.Path, isSelected ? Styles.SelectedLabel : Styles.Label);
153-
GUILayout.Label(string.Format("Locked {0} by {1}", entry.LockedAt, entry.GitLock.Owner.Name), isSelected ? Styles.SelectedLabel : Styles.Label);
153+
GUILayout.Label(string.Format("Locked {0} by {1}", entry.LockedAt, entry.GitLock.Owner.Name), isSelected ? Styles.LocksViewLockedBySelectedStyle : Styles.LocksViewLockedByStyle);
154154
GUILayout.EndVertical();
155155
GUILayout.EndHorizontal();
156156
var itemRect = GUILayoutUtility.GetLastRect();
@@ -467,8 +467,11 @@ private void UnlockSelectedEntry()
467467
}
468468
else
469469
{
470+
var error = ex.Message;
471+
if (error.Contains("exit status 255"))
472+
error = "Failed to unlock: no permissions";
470473
EditorUtility.DisplayDialog(Localization.ReleaseLockActionTitle,
471-
ex.Message,
474+
error,
472475
Localization.Ok);
473476
}
474477

@@ -490,8 +493,11 @@ private void ForceUnlockSelectedEntry()
490493
}
491494
else
492495
{
496+
var error = ex.Message;
497+
if (error.Contains("exit status 255"))
498+
error = "Failed to unlock: no permissions";
493499
EditorUtility.DisplayDialog(Localization.ReleaseLockActionTitle,
494-
ex.Message,
500+
error,
495501
Localization.Ok);
496502
}
497503

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ private static void ContextMenu_Lock()
110110
}
111111
else
112112
{
113+
var error = ex.Message;
114+
if (error.Contains("exit status 255"))
115+
error = "Failed to unlock: no permissions";
113116
EditorUtility.DisplayDialog(Localization.RequestLockActionTitle,
114-
ex.Message,
117+
error,
115118
Localization.Ok);
116119
}
117120

@@ -162,8 +165,11 @@ private static void ContextMenu_Unlock()
162165
}
163166
else
164167
{
168+
var error = ex.Message;
169+
if (error.Contains("exit status 255"))
170+
error = "Failed to unlock: no permissions";
165171
EditorUtility.DisplayDialog(Localization.ReleaseLockActionTitle,
166-
ex.Message,
172+
error,
167173
Localization.Ok);
168174
}
169175

@@ -214,8 +220,11 @@ private static void ContextMenu_UnlockForce()
214220
}
215221
else
216222
{
223+
var error = ex.Message;
224+
if (error.Contains("exit status 255"))
225+
error = "Failed to unlock: no permissions";
217226
EditorUtility.DisplayDialog(Localization.ReleaseLockActionTitle,
218-
ex.Message,
227+
error,
219228
Localization.Ok);
220229
}
221230

0 commit comments

Comments
 (0)