예제 #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);
         }
     }
 }
예제 #2
0
 public void AutoStage(string[] paths)
 {
     if (Threading.IsFlagSet(GitSettingsJson.ThreadingType.Stage))
     {
         AsyncStage(paths);
     }
     else
     {
         GitCommands.Stage(repository, paths);
         MarkDirty(paths);
     }
 }
예제 #3
0
 private void AddSelectedCallback(GitDiffWindow window)
 {
     string[] localPaths = window.GetStatusList().Where(window.IsSelected).SelectMany(e => gitManager.GetPathWithMeta(e.LocalPath)).ToArray();
     if (gitManager.Threading.IsFlagSet(GitSettingsJson.ThreadingType.Stage))
     {
         gitManager.AsyncStage(localPaths).onComplete += (o) => { window.Repaint(); };
     }
     else
     {
         GitCommands.Stage(gitManager.Repository, localPaths);
         gitManager.MarkDirtyAuto(localPaths);
     }
     window.Repaint();
 }
예제 #4
0
        public GitAsyncOperation AsyncStage(string[] paths)
        {
            var operation = asyncManager.QueueWorker(() =>
            {
                GitCommands.Stage(repository, paths);
            }, (o) =>
            {
                MarkDirty(paths);
                asyncStages.RemoveAll(s => s.Equals(o));
                callbacks.IssueAsyncStageOperationDone(o);
            });

            asyncStages.Add(new AsyncStageOperation(operation, paths));
            return(operation);
        }
예제 #5
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"));
            }
        }