Example #1
0
 private void PostprocessStage(string[] paths)
 {
     if (repository == null || !IsValidRepo)
     {
         return;
     }
     if (prefs.GetBool(UnityEditorGitPrefs.DisablePostprocess))
     {
         return;
     }
     string[] pathsFinal = paths.Where(a => !IsEmptyFolder(a)).SelectMany(GetPathWithMeta).ToArray();
     if (pathsFinal.Length > 0)
     {
         bool autoStage = gitSettings != null && gitSettings.AutoStage;
         if (Threading.IsFlagSet(GitSettingsJson.ThreadingType.Stage))
         {
             if (autoStage)
             {
                 AsyncStage(pathsFinal);
             }
             else
             {
                 MarkDirty(pathsFinal);
             }
         }
         else
         {
             if (autoStage)
             {
                 GitCommands.Stage(repository, pathsFinal);
             }
             MarkDirty(pathsFinal);
         }
     }
 }
Example #2
0
 public void AutoUnstage(string[] paths)
 {
     if (Threading.IsFlagSet(GitSettingsJson.ThreadingType.Unstage))
     {
         AsyncUnstage(paths);
     }
     else
     {
         GitCommands.Unstage(repository, paths);
         MarkDirty(paths);
     }
 }
Example #3
0
 public void AutoStage(params string[] localPaths)
 {
     if (Threading.IsFlagSet(GitSettingsJson.ThreadingType.Stage))
     {
         AsyncStage(localPaths);
     }
     else
     {
         GitCommands.Stage(repository, localPaths);
         MarkDirtyAuto(localPaths);
     }
 }
Example #4
0
 private void RemoveSelectedCallback(GitDiffWindow window)
 {
     string[] localPaths = window.GetStatusList().Where(window.IsSelected).SelectMany(e => gitManager.GetPathWithMeta(e.LocalPath)).ToArray();
     if (gitManager.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Unstage))
     {
         gitManager.AsyncUnstage(localPaths).onComplete += (o) => { window.Repaint(); };
     }
     else
     {
         GitCommands.Unstage(gitManager.Repository, localPaths);
         gitManager.MarkDirtyAuto(localPaths);
     }
     window.Repaint();
 }
Example #5
0
        private void OnWizardCreate()
        {
            checkoutOptions.CheckoutModifiers = force ? CheckoutModifiers.Force : CheckoutModifiers.None;
            var branch = gitManager.Repository.Branches[branchNames[selectedBranch]];

            if (branch != null)
            {
                GitCommands.Checkout(gitManager.Repository, branch, checkoutOptions);
            }
            else
            {
                logger.LogFormat(LogType.Error, "Could not find branch with name: {0}", branchNames[selectedBranch]);
            }
        }
Example #6
0
        public GitAsyncOperation AsyncUnstage(string[] paths)
        {
            var operation = asyncManager.QueueWorker(() =>
            {
                GitCommands.Unstage(repository, paths);
            }, (o) =>
            {
                MarkDirty(paths);
                asyncStages.RemoveAll(s => s.Equals(o));
                callbacks.IssueAsyncStageOperationDone(o);
            });

            asyncStages.Add(new AsyncStageOperation(operation, paths));
            return(operation);
        }
Example #7
0
 private void OnWizardCreate()
 {
     try
     {
         MergeResult mergeResult = GitCommands.Pull(gitManager.Repository, gitManager.Signature, pullOptions);
         OnMergeComplete(mergeResult, "Pull");
     }
     catch (Exception e)
     {
         logger.LogException(e);
     }
     finally
     {
         EditorUtility.ClearProgressBar();
     }
 }
Example #8
0
        internal void Build(FileStatus fileStatus, GenericMenu menu, GitDiffWindow window)
        {
            menu.AddItem(new GUIContent("Select All"), false, () => SelectFilteredCallback(fileStatus, window));
            if (GitManager.CanStage(fileStatus))
            {
                menu.AddItem(new GUIContent("Add All"), false, () =>
                {
                    string[] paths = window.GetStatusList().Where(s => s.State.IsFlagSet(fileStatus)).SelectMany(s => gitManager.GetPathWithMeta(s.LocalPath)).ToArray();
                    if (gitManager.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Stage))
                    {
                        gitManager.AsyncStage(paths).onComplete += (o) => { window.Repaint(); };
                    }
                    else
                    {
                        GitCommands.Stage(gitManager.Repository, paths);
                        gitManager.MarkDirtyAuto(paths);
                    }
                    window.Repaint();
                });
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Add All"));
            }

            if (GitManager.CanUnstage(fileStatus))
            {
                menu.AddItem(new GUIContent("Remove All"), false, () =>
                {
                    string[] paths = window.GetStatusList().Where(s => s.State.IsFlagSet(fileStatus)).SelectMany(s => gitManager.GetPathWithMeta(s.LocalPath)).ToArray();
                    if (gitManager.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Unstage))
                    {
                        gitManager.AsyncUnstage(paths).onComplete += (o) => { window.Repaint(); };
                    }
                    else
                    {
                        GitCommands.Unstage(gitManager.Repository, paths);
                        gitManager.MarkDirtyAuto(paths);
                    }
                    window.Repaint();
                });
            }
            else
            {
                menu.AddDisabledItem(new GUIContent("Remove All"));
            }
        }
Example #9
0
        public override void OnGUI(Rect rect)
        {
            GUILayout.Label(GitGUI.GetTempContent("Switch to: " + branch.FriendlyName), GitGUI.Styles.BigTitle, GUILayout.ExpandWidth(true));
            force = EditorGUILayout.Toggle(GitGUI.GetTempContent("Force", "Override working tree changes"), force);
            if (GUILayout.Button(GitGUI.GetTempContent("Siwtch")))
            {
                CheckoutOptions checkoutOptions = new CheckoutOptions()
                {
                    OnCheckoutNotify   = OnCheckoutNotify,
                    OnCheckoutProgress = OnCheckoutProgress
                };

                if (force)
                {
                    checkoutOptions.CheckoutModifiers = CheckoutModifiers.Force;
                }

                if (branch != null)
                {
                    try
                    {
                        GitCommands.Checkout(gitManager.Repository, branch, checkoutOptions);
                    }
                    catch (Exception e)
                    {
                        logger.LogFormat(LogType.Error, "There was a problem while switching to branch: {0}", branch.CanonicalName);
                        logger.LogException(e);
                    }
                    finally
                    {
                        gitCallbacks.IssueAssetDatabaseRefresh();
                        gitManager.MarkDirty(true);
                    }
                }
                else
                {
                    logger.Log(LogType.Error, "Trying to switch to null branch");
                }
            }
        }
Example #10
0
        private bool AutoFetchChanges()
        {
            if (gitManager.Repository == null || !initializer.IsValidRepo || !gitSettings.AutoFetch)
            {
                return(false);
            }
            Remote remote = gitManager.Repository.Network.Remotes.FirstOrDefault();

            if (remote == null)
            {
                return(false);
            }
            GitProfilerProxy.BeginSample("Git automatic fetching");
            try
            {
                GitCommands.Fetch(gitManager.Repository, remote, new FetchOptions()
                {
                    CredentialsProvider         = credentialsManager.FetchChangesAutoCredentialHandler,
                    OnTransferProgress          = gitManager.FetchTransferProgressHandler,
                    RepositoryOperationStarting = (context) =>
                    {
                        logger.Log(LogType.Log, "Repository Operation Starting");
                        return(true);
                    }
                });
                //Debug.LogFormat("Auto Fetch From remote: {0} - ({1}) successful.", remote.Name, remote.Url);
            }
            catch (Exception e)
            {
                logger.LogFormat(LogType.Error, "Automatic Fetching from remote: {0} with URL: {1} Failed!", remote.Name, remote.Url);
                logger.LogException(e);
            }
            finally
            {
                EditorUtility.ClearProgressBar();
                GitProfilerProxy.EndSample();
            }
            return(false);
        }
Example #11
0
 private void PostprocessUnstage(string[] paths)
 {
     if (repository == null || !IsValidRepo)
     {
         return;
     }
     if (prefs.GetBool(UnityEditorGitPrefs.DisablePostprocess))
     {
         return;
     }
     string[] pathsFinal = paths.SelectMany(GetPathWithMeta).ToArray();
     if (pathsFinal.Length > 0)
     {
         if (gitSettings != null && Threading.IsFlagSet(GitSettingsJson.ThreadingType.Unstage))
         {
             AsyncUnstage(pathsFinal);
         }
         else
         {
             GitCommands.Unstage(repository, pathsFinal);
             MarkDirty(pathsFinal);
         }
     }
 }
Example #12
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();
            }
        }