Example #1
0
 public void AutoUnstage(string[] paths)
 {
     if (Threading.IsFlagSet(GitSettingsJson.ThreadingType.Unstage))
     {
         AsyncUnstage(paths);
     }
     else
     {
         GitCommands.Unstage(repository, paths);
         MarkDirty(paths);
     }
 }
Example #2
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 #3
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 #4
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 #5
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);
         }
     }
 }