private void BuildOptions(GenericMenu menu, string path, bool initActive)
        {
            if (initActive)
            {
                menu.AddItem(new GUIContent("Init/Init"), false, () =>
                {
                    gitManager.Repository.Submodules.Init(path, false);
                    gitManager.MarkDirty(true);
                });
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Init/Init"));
            }

            menu.AddItem(new GUIContent("Init/Force"), false, () =>
            {
                gitManager.Repository.Submodules.Init(path, true);
                gitManager.MarkDirty(true);
            });
            menu.AddItem(new GUIContent("Update\\Info"), false, () =>
            {
                var window = UniGitLoader.GetWindow <GitSubModuleOptionsWizard>(true);
                window.Init(path);
            });
        }
Beispiel #2
0
        public static void UpdateModule()
        {
            var path   = Selection.assetGUIDs.Select(AssetDatabase.GUIDToAssetPath).FirstOrDefault();
            var window = UniGitLoader.GetWindow <GitSubModuleOptionsWizard>();

            window.Init(path);
        }
 private void CommitAndPushCallback(GitDiffWindow window)
 {
     if (gitSettings.ExternalsType.IsFlagSet(GitSettingsJson.ExternalsTypeEnum.Commit) || EditorUtility.DisplayDialog("Are you sure?", "Are you sure you want to commit the changes and then push them?", "➔ Commit and Push", "✖ Cancel"))
     {
         if (window.Commit())
         {
             UniGitLoader.DisplayWizard <GitPushWizard>("Git Push", "Push");
         }
     }
 }
Beispiel #4
0
        public void ShowDiff(string path, [NotNull] Commit oldCommit, [NotNull] Commit newCommit, GitExternalManager externalManager)
        {
            if (externalManager.TakeDiff(path, oldCommit, newCommit))
            {
                return;
            }

            var window = UniGitLoader.GetWindow <GitDiffInspector>();

            window.Init(path, oldCommit, newCommit);
        }
Beispiel #5
0
 private void GoToMerge()
 {
     if (externalManager.TakeMerge())
     {
         gitManager.MarkDirty();
     }
     else
     {
         UniGitLoader.DisplayWizard <GitMergeWizard>("Git Merge", "Merge");
     }
 }
Beispiel #6
0
 private void GoToPush()
 {
     if (externalManager.TakePush())
     {
         gitManager.MarkDirty();
     }
     else
     {
         var wizard = UniGitLoader.DisplayWizard <GitPushWizard>("Git Push", "Push");
         wizard.Init(selectedBranch.LoadBranch(gitManager));
     }
 }
Beispiel #7
0
        public void ShowBlameWizard(string path, GitExternalManager externalManager)
        {
            if (!string.IsNullOrEmpty(path))
            {
                if (externalManager.TakeBlame(path))
                {
                    return;
                }

                var blameWizard = UniGitLoader.GetWindow <GitBlameWizard>(true);
                blameWizard.SetBlamePath(path);
            }
        }
Beispiel #8
0
 private void GoToPull()
 {
     if (externalManager.TakePull())
     {
         gitManager.Callbacks.IssueAssetDatabaseRefresh();
         gitManager.MarkDirty();
     }
     else
     {
         var wizard = UniGitLoader.DisplayWizard <GitPullWizard>("Git Pull", "Pull");
         wizard.Init(selectedBranch.LoadBranch(gitManager));
     }
 }
Beispiel #9
0
        private void GoToFetch()
        {
            var branch = selectedBranch.LoadBranch(gitManager);

            if (externalManager.TakeFetch(branch.Remote.Name))
            {
                gitManager.MarkDirty();
            }
            else
            {
                var wizard = UniGitLoader.DisplayWizard <GitFetchWizard>("Git Fetch", "Fetch");
                wizard.Init(branch);
            }
        }
Beispiel #10
0
        protected void OnMergeComplete(MergeResult result, string mergeType)
        {
            var historyWindow = UniGitLoader.FindWindow <GitHistoryWindow>();
            var diffWindow    = UniGitLoader.FindWindow <GitDiffWindow>();

            switch (result.Status)
            {
            case MergeStatus.UpToDate:
                if (historyWindow != null)
                {
                    historyWindow.ShowNotification(new GUIContent(string.Format("Everything is Up to date. Nothing to {0}.", mergeType)));
                }
                break;

            case MergeStatus.FastForward:
                if (historyWindow != null)
                {
                    historyWindow.ShowNotification(new GUIContent(mergeType + " Complete with Fast Forwarding."));
                }
                break;

            case MergeStatus.NonFastForward:
                if (diffWindow != null)
                {
                    diffWindow.ShowNotification(new GUIContent("Do a merge commit in order to push changes."));
                    diffWindow.SetCommitMessage(gitManager.Repository.Info.Message);
                }
                else
                {
                    GitDiffWindow.SetCommitMessage(gitManager, gitManager.Repository.Info.Message);
                }
                Debug.Log(mergeType + " Complete without Fast Forwarding.");
                break;

            case MergeStatus.Conflicts:
                GUIContent content = GitGUI.IconContent("console.warnicon", "There are merge conflicts!");
                if (diffWindow != null)
                {
                    diffWindow.ShowNotification(content);
                    diffWindow.SetCommitMessage(gitManager.Repository.Info.Message);
                }
                else
                {
                    GitDiffWindow.SetCommitMessage(gitManager, gitManager.Repository.Info.Message);
                }
                break;
            }
            gitManager.MarkDirty();
            Debug.LogFormat("{0} Status: {1}", mergeType, result.Status);
        }
Beispiel #11
0
        public void ShowDiff(string path, GitExternalManager externalManager)
        {
            if (string.IsNullOrEmpty(path) || Repository == null)
            {
                return;
            }
            if (externalManager.TakeDiff(path))
            {
                return;
            }

            var window = UniGitLoader.GetWindow <GitDiffInspector>();

            window.Init(path);
        }
Beispiel #12
0
 private void OnWizardCreate()
 {
     try
     {
         using (var repository = new Repository(gitManager.GetCurrentRepoPath()))
         {
             if (branchNames.Length > 0 && selectedBranch < branchNames.Length)
             {
                 repository.Network.Push(repository.Branches[branchNames[selectedBranch]], pushOptions);
                 gitManager.MarkDirty();
                 var window = UniGitLoader.FindWindow <GitHistoryWindow>();
                 if (window != null)
                 {
                     window.ShowNotification(new GUIContent("Push Complete"));
                 }
             }
             else
             {
                 logger.Log(LogType.Warning, "No Branch Selected.");
             }
         }
     }
     catch (Exception e)
     {
         if (e is NonFastForwardException)
         {
             GUIContent content = GitGUI.IconContent("console.warnicon", "Could not push changes to remote. Merge changes with remote before pushing.");
             if (focusedWindow != null)
             {
                 focusedWindow.ShowNotification(content);
             }
             else
             {
                 GitGUI.ShowNotificationOnWindow <GitHistoryWindow>(content, false);
             }
         }
         logger.LogException(e);
     }
     finally
     {
         EditorUtility.ClearProgressBar();
     }
 }
Beispiel #13
0
        public void ShowDiffPrev(string path, GitExternalManager externalManager)
        {
            if (string.IsNullOrEmpty(path) || Repository == null)
            {
                return;
            }
            var lastCommit = Repository.Commits.QueryBy(path).Skip(1).FirstOrDefault();

            if (lastCommit == null)
            {
                return;
            }
            if (externalManager.TakeDiff(path, lastCommit.Commit))
            {
                return;
            }

            var window = UniGitLoader.GetWindow <GitDiffInspector>();

            window.Init(path, lastCommit.Commit);
        }
Beispiel #14
0
        private void OnWizardCreate()
        {
            try
            {
                GitCommands.Fetch(gitManager.Repository, remotes[selectedRemote], fetchOptions);
#if UNITY_EDITOR
                logger.Log(LogType.Log, "Fetch Complete");
#endif
                var window = UniGitLoader.FindWindow <GitHistoryWindow>();
                if (window != null)
                {
                    window.ShowNotification(new GUIContent("Fetch Complete"));
                }
                gitManager.MarkDirty(true);
            }
            catch (Exception e)
            {
                logger.LogException(e);
            }
            finally
            {
                EditorUtility.ClearProgressBar();
            }
        }
Beispiel #15
0
 private static void OpenGitRemoteToolsWindow()
 {
     UniGitLoader.GetWindow <GitRemoteToolsWindow>();
 }
Beispiel #16
0
 private static void OpenGitSettingsWindow()
 {
     UniGitLoader.GetWindow <GitSettingsWindow>();
 }
Beispiel #17
0
 private static void OpenGitDiffWindow()
 {
     UniGitLoader.GetWindow <GitDiffWindow>();
 }
Beispiel #18
0
 private static void OpenGitHistoryWindow()
 {
     UniGitLoader.GetWindow <GitHistoryWindow>();
 }
Beispiel #19
0
        public override void OnGUI(Rect rect)
        {
            if (Event.current.type == EventType.MouseMove)
            {
                editorWindow.Repaint();
            }
            int stashCount = stashCollection.Count();

            EditorGUILayout.BeginHorizontal("IN BigTitle");
            if (GUILayout.Button(GitGUI.GetTempContent("Stash Save", gitOverlay.icons.stashIcon.image, "Save changes in working directory to stash.")))
            {
                UniGitLoader.GetWindow <GitStashSaveWizard>(true);
            }
            EditorGUILayout.EndHorizontal();

            GUI.enabled = true;
            stashScroll = EditorGUILayout.BeginScrollView(stashScroll, GUILayout.ExpandHeight(true));
            int stashId = 0;

            foreach (var stash in stashCollection)
            {
                string     msg          = stash.Message;
                GUIContent stashContent = GitGUI.GetTempContent(msg);
                Rect       stastRect    = GUILayoutUtility.GetRect(stashContent, stashStyle);
                if (Event.current.type == EventType.Repaint)
                {
                    stashStyle.Draw(stastRect, stashContent, stastRect.Contains(Event.current.mousePosition) || stashId == selectedStash, false, false, false);
                }
                else if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && stastRect.Contains(Event.current.mousePosition))
                {
                    selectedStash = stashId;
                }
                stashId++;
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndScrollView();

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal("ProjectBrowserBottomBarBg");
            GUI.enabled = stashCount > 0;
            if (GUILayout.Button(GitGUI.GetTempContent("Apply", "Apply stash to working directory."), EditorStyles.miniButtonLeft))
            {
                if (EditorUtility.DisplayDialog("Apply Stash: " + selectedStash, "Are you sure you want to apply stash ? This will override your current working directory!", "Apply", "Cancel"))
                {
                    stashCollection.Apply(selectedStash);
                    gitManager.MarkDirty(true);
                    gitCallbacks.IssueAssetDatabaseRefresh();
                }
            }
            if (GUILayout.Button(GitGUI.GetTempContent("Pop", "Remove and apply stash to working directory."), EditorStyles.miniButtonMid))
            {
                if (EditorUtility.DisplayDialog("Pop Stash: " + selectedStash, "Are you sure you want to pop the stash ? This will override your current working directory and remove the stash from the list.", "Pop and Apply", "Cancel"))
                {
                    stashCollection.Pop(selectedStash);
                    gitManager.MarkDirty(true);
                    gitCallbacks.IssueAssetDatabaseRefresh();
                }
            }
            if (GUILayout.Button(GitGUI.GetTempContent("Remove", "Remove stash from list"), EditorStyles.miniButtonRight))
            {
                if (EditorUtility.DisplayDialog("Remove Stash: " + selectedStash, "Are you sure you want to remove the stash ? This action cannot be undone!", "Remove", "Cancel"))
                {
                    stashCollection.Remove(selectedStash);
                }
            }
            GUI.enabled = true;
            EditorGUILayout.EndHorizontal();
        }