private void GoToFetch() { var branch = selectedBranch.LoadBranch(); if (GitExternalManager.TakeFetch(branch.Remote.Name)) { GitManager.MarkDirty(); } else { ScriptableWizard.DisplayWizard <GitFetchWizard>("Fetch", "Fetch").Init(branch); } }
private void DoToolbar(Rect rect, RepositoryInformation info) { GitProfilerProxy.BeginSample("Git History Window Toolbar GUI", this); GUI.Box(rect, GUIContent.none, "Toolbar"); Rect btRect = new Rect(rect.x, rect.y, 64, rect.height); GUIContent pushButtonContent = GitGUI.GetTempContent(EditorGUIUtility.FindTexture("CollabPush"), "Push", "Push local changes to a remote repository."); if (info.CurrentOperation == CurrentOperation.Merge) { GUI.enabled = false; pushButtonContent.tooltip = "Do a Merge commit before pushing."; } else if (hasConflicts) { GUI.enabled = false; pushButtonContent.tooltip = "Resolve conflicts before pushing."; } if (GUI.Button(btRect, pushButtonContent, "toolbarbutton")) { if (GitExternalManager.TakePush()) { GitManager.MarkDirty(); } else { ScriptableWizard.DisplayWizard <GitPushWizard>("Push", "Push").Init(selectedBranch.LoadBranch()); } } btRect = new Rect(btRect.x + 64, btRect.y, 64, btRect.height); GUI.enabled = !hasConflicts; if (GUI.Button(btRect, GitGUI.GetTempContent(EditorGUIUtility.IconContent("CollabPull").image, "Pull", hasConflicts ? "Must resolve conflicts before pulling" : "Pull changes from remote repository by fetching them and then merging them. This is the same as calling Fetch then Merge."), "toolbarbutton")) { Branch branch = selectedBranch.LoadBranch(); if (branch != null) { if (GitExternalManager.TakePull()) { AssetDatabase.Refresh(); GitManager.MarkDirty(); } else { ScriptableWizard.DisplayWizard <GitPullWizard>("Pull", "Pull").Init(branch); } } else { Debug.LogError("Could Not Load Branch"); } } btRect = new Rect(btRect.x + 70, btRect.y, 64, btRect.height); if (GUI.Button(btRect, GitGUI.GetTempContent(EditorGUIUtility.IconContent("UniGit/GitFetch").image, "Fetch", "Get changes from remote repository but do not merge them."), "toolbarbutton")) { Branch branch = selectedBranch.LoadBranch(); if (branch != null) { if (branch.Remote != null) { if (GitExternalManager.TakeFetch(branch.Remote.Name)) { GitManager.MarkDirty(); } else { ScriptableWizard.DisplayWizard <GitFetchWizard>("Fetch", "Fetch").Init(branch); } } else { Debug.LogError("Branch does not have a remote"); } } else { Debug.LogError("Could not Load Branch"); } } btRect = new Rect(btRect.x + 64, btRect.y, 64, btRect.height); if (GUI.Button(btRect, GitGUI.GetTempContent(EditorGUIUtility.IconContent("UniGit/GitMerge").image, "Merge", hasConflicts ? "Must Resolve conflict before merging" : "Merge fetched changes from remote repository. Changes from the latest fetch will be merged."), "toolbarbutton")) { if (GitExternalManager.TakeMerge()) { GitManager.MarkDirty(); } else { ScriptableWizard.DisplayWizard <GitMergeWizard>("Merge", "Merge"); } } GUI.enabled = true; btRect = new Rect(rect.x + rect.width - 64, btRect.y, 64, btRect.height); if (GUI.Button(btRect, GitGUI.GetTempContent(string.IsNullOrEmpty(selectedBranchName) ? "Branch" : selectedBranch.FriendlyName), "ToolbarDropDown")) { GenericMenu selectBranchMenu = new GenericMenu(); foreach (var branch in cachedBranches) { selectBranchMenu.AddItem(new GUIContent(branch.FriendlyName), false, (b) => { selectedBranchName = (string)b; UpdateSelectedBranch(); }, branch.FriendlyName); } selectBranchMenu.ShowAsContext(); } btRect = new Rect(btRect.x - 64, btRect.y, 64, btRect.height); GUI.enabled = GitManager.Settings.ExternalsType.HasFlag(GitSettings.ExternalsTypeEnum.Switch) || (!selectedBranch.IsRemote && !selectedBranch.IsCurrentRepositoryHead); if (GUI.Button(btRect, GitGUI.GetTempContent(EditorGUIUtility.IconContent("UniGit/GitCheckout").image, "Switch", selectedBranch.IsRemote ? "Cannot switch to remote branches." : selectedBranch.IsCurrentRepositoryHead ? "This branch is the active one" : "Switch to another branch"), "toolbarbutton")) { if (GitExternalManager.TakeSwitch()) { AssetDatabase.Refresh(); GitManager.MarkDirty(); } //todo Implement native switching } GUI.enabled = true; GitProfilerProxy.EndSample(); }
private void DoToolbar(Rect rect, RepositoryInformation info) { Profiler.BeginSample("Git History Window Toolbar GUI"); GUI.Box(rect, GUIContent.none, "Toolbar"); Rect btRect = new Rect(rect.x, rect.y, 64, rect.height); GUIContent pushButtonContent = new GUIContent("Push", EditorGUIUtility.FindTexture("CollabPush"), "Push local changes to a remote repository."); if (info.CurrentOperation == CurrentOperation.Merge) { GUI.enabled = false; pushButtonContent.tooltip = "Do a Merge commit before pushing."; } else if (hasConflicts) { GUI.enabled = false; pushButtonContent.tooltip = "Resolve conflicts before pushing."; } if (GUI.Button(btRect, pushButtonContent, "toolbarbutton")) { if (GitExternalManager.TakePush()) { GitManager.Update(); } else { ScriptableWizard.DisplayWizard <GitPushWizard>("Push", "Push").Init(selectedBranch.LoadBranch()); } } btRect = new Rect(btRect.x + 64, btRect.y, 64, btRect.height); GUI.enabled = !hasConflicts; GUIContent pullButtonContent = EditorGUIUtility.IconContent("CollabPull"); pullButtonContent.tooltip = hasConflicts ? "Must resolve conflicts before pulling" : "Pull changes from remote repository by fetching them and then merging them. This is the same as calling Fetch then Merge."; pullButtonContent.text = "Pull"; if (GUI.Button(btRect, pullButtonContent, "toolbarbutton")) { Branch branch = selectedBranch.LoadBranch(); if (GitExternalManager.TakePull()) { AssetDatabase.Refresh(); GitManager.Update(); } else { ScriptableWizard.DisplayWizard <GitPullWizard>("Pull", "Pull").Init(branch); } } btRect = new Rect(btRect.x + 70, btRect.y, 64, btRect.height); GUIContent fetchButtonContent = EditorGUIUtility.IconContent("UniGit/GitFetch"); fetchButtonContent.tooltip = "Get changes from remote repository but do not merge them."; fetchButtonContent.text = "Fetch"; if (GUI.Button(btRect, fetchButtonContent, "toolbarbutton")) { Branch branch = selectedBranch.LoadBranch(); if (GitExternalManager.TakeFetch(branch.Remote.Name)) { GitManager.Update(); } else { ScriptableWizard.DisplayWizard <GitFetchWizard>("Fetch", "Fetch").Init(branch); } } btRect = new Rect(btRect.x + 64, btRect.y, 64, btRect.height); GUIContent mergeButtonContent = EditorGUIUtility.IconContent("UniGit/GitMerge"); mergeButtonContent.tooltip = hasConflicts ? "Must Resolve conflict before merging" : "Merge fetched changes from remote repository. Changes from the latest fetch will be merged."; mergeButtonContent.text = "Merge"; if (GUI.Button(btRect, mergeButtonContent, "toolbarbutton")) { if (GitExternalManager.TakeMerge()) { GitManager.Update(); } else { ScriptableWizard.DisplayWizard <GitMergeWizard>("Merge", "Merge"); } } GUI.enabled = true; btRect = new Rect(rect.x + rect.width - 64, btRect.y, 64, btRect.height); if (GUI.Button(btRect, new GUIContent(string.IsNullOrEmpty(selectedBranchName) ? "Branch" : selectedBranch.FriendlyName), "ToolbarDropDown")) { GenericMenu selectBranchMenu = new GenericMenu(); foreach (var branch in cachedBranches) { selectBranchMenu.AddItem(new GUIContent(branch.FriendlyName), false, (b) => { selectedBranchName = (string)b; UpdateSelectedBranch(); }, branch.FriendlyName); } selectBranchMenu.ShowAsContext(); } btRect = new Rect(btRect.x - 64, btRect.y, 64, btRect.height); GUI.enabled = !selectedBranch.IsRemote && !selectedBranch.IsCurrentRepositoryHead; GUIContent checkoutButtonContent = EditorGUIUtility.IconContent("UniGit/GitCheckout"); checkoutButtonContent.text = "Switch"; checkoutButtonContent.tooltip = selectedBranch.IsRemote ? "Cannot switch to remote branches." : selectedBranch.IsCurrentRepositoryHead ? "This branch is the active one" : "Switch to another branch"; if (GUI.Button(btRect, checkoutButtonContent, "toolbarbutton")) { } GUI.enabled = true; Profiler.EndSample(); }