Browse Source

Added color coding in stash window.
Small beautifications done

sujith 1 month ago
parent
commit
821c680ddd

+ 1 - 1
Assets/Better Git/Arbitrator/Editor/GUI/ArbitratorWindow.cs

@@ -132,7 +132,7 @@ namespace Terra.Arbitrator.GUI
                 
                 var stashSelections = _controller.Changes?.Count(c => c.IsSelectedForCommit) ?? 0;
                 EditorGUI.BeginDisabledGroup(stashSelections == 0);
-                if (GUILayout.Button(new GUIContent("Stash", EditorGUIUtility.IconContent("d_AlphabeticalSorting").image), EditorStyles.toolbarButton, GUILayout.Width(80)))
+                if (GUILayout.Button(new GUIContent("Stash", EditorGUIUtility.IconContent("d_Import").image), EditorStyles.toolbarButton, GUILayout.Width(80)))
                 {
                     _controller.StashSelectedFiles();
                 }

+ 36 - 8
Assets/Better Git/Arbitrator/Editor/GUI/StashedChangesWindow.cs

@@ -75,15 +75,43 @@ namespace Terra.Arbitrator.GUI
             {
                 EditorGUILayout.BeginHorizontal(EditorStyles.helpBox);
                 
-                var status = change.Status switch {
-                    LibGit2Sharp.ChangeKind.Added => "[+]",
-                    LibGit2Sharp.ChangeKind.Deleted => "[-]",
-                    LibGit2Sharp.ChangeKind.Modified => "[M]",
-                    _ => "[?]"
-                };
-                
+                string status;
+                Color statusColor;
+
+                switch (change.Status)
+                {
+                    case LibGit2Sharp.ChangeKind.Added:
+                        status = "[+]";
+                        statusColor = Color.green;
+                        break;
+                    case LibGit2Sharp.ChangeKind.Deleted:
+                        status = "[-]";
+                        statusColor = Color.red;
+                        break;
+                    case LibGit2Sharp.ChangeKind.Modified:
+                        status = "[M]";
+                        statusColor = new Color(1.0f, 0.6f, 0.0f);
+                        break;
+                    case LibGit2Sharp.ChangeKind.Renamed:
+                        status = "[R]";
+                        statusColor = new Color(0.6f, 0.6f, 1.0f);
+                        break;
+                    default:
+                        status = "[?]";
+                        statusColor = Color.white;
+                        break;
+                }
+
+                var originalColor = UnityEngine.GUI.color;
+                UnityEngine.GUI.color = statusColor;
                 EditorGUILayout.LabelField(new GUIContent(status, change.Status.ToString()), GUILayout.Width(25));
-                EditorGUILayout.LabelField(new GUIContent(change.FilePath, change.FilePath));
+                UnityEngine.GUI.color = originalColor;
+                
+                var filePathDisplay = change.Status == LibGit2Sharp.ChangeKind.Renamed
+                    ? $"{change.OldFilePath} -> {change.FilePath}"
+                    : change.FilePath;
+
+                EditorGUILayout.LabelField(new GUIContent(filePathDisplay, filePathDisplay));
 
                 if (GUILayout.Button("Diff", GUILayout.Width(60)))
                 {