예제 #1
0
파일: Status.cs 프로젝트: oqewok/gitter
        /// <summary>Remove untracked and/or ignored files and (optionally) directories.</summary>
        /// <param name="includePattern">Files to clean.</param>
        /// <param name="excludePattern">Files to save.</param>
        /// <param name="mode">Clean mode.</param>
        /// <param name="removeDirectories"><c>true</c> to remove directories.</param>
        public void Clean(string includePattern, string excludePattern, CleanFilesMode mode, bool removeDirectories)
        {
            var parameters = GetCleanFilesParameters(includePattern, excludePattern, mode, removeDirectories, true);

            try
            {
                using (Repository.Monitor.BlockNotifications(
                           RepositoryNotifications.IndexUpdated,
                           RepositoryNotifications.WorktreeUpdated))
                {
                    Repository.Accessor.CleanFiles.Invoke(parameters);
                }
            }
            finally
            {
                Refresh();
            }
        }
예제 #2
0
파일: Status.cs 프로젝트: oqewok/gitter
        /// <summary>Returns a list of files which will be removed by a clean funciton.</summary>
        /// <param name="includePattern">Files to clean.</param>
        /// <param name="excludePattern">Files to save.</param>
        /// <param name="mode">Clean mode.</param>
        /// <param name="removeDirectories"><c>true</c> to remove directories.</param>
        /// <returns>Files that will be removed by a Clean() call.</returns>
        public IList <TreeItem> GetFilesToClean(string includePattern, string excludePattern, CleanFilesMode mode, bool removeDirectories)
        {
            IList <string> files;
            var            parameters = GetCleanFilesParameters(includePattern, excludePattern, mode, removeDirectories);

            using (var block = Repository.Monitor.BlockNotifications(RepositoryNotifications.IndexUpdated))
            {
                files = Repository.Accessor.QueryFilesToClean.Invoke(parameters);
            }
            return(RestoreFilesToCleanList(files));
        }
예제 #3
0
파일: Status.cs 프로젝트: oqewok/gitter
        /// <summary>Returns a list of files which will be removed by a clean funciton.</summary>
        /// <param name="includePattern">Files to clean.</param>
        /// <param name="excludePattern">Files to save.</param>
        /// <param name="mode">Clean mode.</param>
        /// <param name="removeDirectories"><c>true</c> to remove directories.</param>
        /// <returns>Files that will be removed by a Clean() call.</returns>
        public Task <IList <TreeItem> > GetFilesToCleanAsync(string includePattern, string excludePattern, CleanFilesMode mode, bool removeDirectories, IProgress <OperationProgress> progress, CancellationToken cancellationToken)
        {
            if (progress != null)
            {
                progress.Report(new OperationProgress(Resources.StrsLookingForFiles.AddEllipsis()));
            }
            var parameters = GetCleanFilesParameters(includePattern, excludePattern, mode, removeDirectories);
            var block      = Repository.Monitor.BlockNotifications(RepositoryNotifications.IndexUpdated);

            return(Repository.Accessor.QueryFilesToClean.InvokeAsync(parameters, progress, cancellationToken)
                   .ContinueWith(
                       t =>
            {
                block.Dispose();
                var files = TaskUtility.UnwrapResult(t);
                return RestoreFilesToCleanList(files);
            },
                       CancellationToken.None,
                       TaskContinuationOptions.ExecuteSynchronously,
                       TaskScheduler.Default));
        }
예제 #4
0
파일: Status.cs 프로젝트: oqewok/gitter
 private static CleanFilesParameters GetCleanFilesParameters(string includePattern, string excludePattern, CleanFilesMode mode, bool removeDirectories, bool force = false)
 {
     return(new CleanFilesParameters(includePattern)
     {
         ExcludePatterns = new string[] { excludePattern },
         Mode = mode,
         RemoveDirectories = removeDirectories,
         Force = force,
     });
 }
예제 #5
0
파일: Status.cs 프로젝트: Kuzq/gitter
 private static CleanFilesParameters GetCleanFilesParameters(string includePattern, string excludePattern, CleanFilesMode mode, bool removeDirectories, bool force = false)
 {
     return new CleanFilesParameters(includePattern)
     {
         ExcludePatterns   = new string[] { excludePattern },
         Mode              = mode,
         RemoveDirectories = removeDirectories,
         Force             = force,
     };
 }
예제 #6
0
파일: Status.cs 프로젝트: Kuzq/gitter
 /// <summary>Returns a list of files which will be removed by a clean funciton.</summary>
 /// <param name="includePattern">Files to clean.</param>
 /// <param name="excludePattern">Files to save.</param>
 /// <param name="mode">Clean mode.</param>
 /// <param name="removeDirectories"><c>true</c> to remove directories.</param>
 /// <returns>Files that will be removed by a Clean() call.</returns>
 public Task<IList<TreeItem>> GetFilesToCleanAsync(string includePattern, string excludePattern, CleanFilesMode mode, bool removeDirectories, IProgress<OperationProgress> progress, CancellationToken cancellationToken)
 {
     if(progress != null)
     {
         progress.Report(new OperationProgress(Resources.StrsLookingForFiles.AddEllipsis()));
     }
     var parameters = GetCleanFilesParameters(includePattern, excludePattern, mode, removeDirectories);
     var block = Repository.Monitor.BlockNotifications(RepositoryNotifications.IndexUpdated);
     return Repository.Accessor.QueryFilesToClean.InvokeAsync(parameters, progress, cancellationToken)
         .ContinueWith(
         t =>
         {
             block.Dispose();
             var files = TaskUtility.UnwrapResult(t);
             return RestoreFilesToCleanList(files);
         },
         CancellationToken.None,
         TaskContinuationOptions.ExecuteSynchronously,
         TaskScheduler.Default);
 }
예제 #7
0
파일: Status.cs 프로젝트: Kuzq/gitter
 /// <summary>Returns a list of files which will be removed by a clean funciton.</summary>
 /// <param name="includePattern">Files to clean.</param>
 /// <param name="excludePattern">Files to save.</param>
 /// <param name="mode">Clean mode.</param>
 /// <param name="removeDirectories"><c>true</c> to remove directories.</param>
 /// <returns>Files that will be removed by a Clean() call.</returns>
 public IList<TreeItem> GetFilesToClean(string includePattern, string excludePattern, CleanFilesMode mode, bool removeDirectories)
 {
     IList<string> files;
     var parameters = GetCleanFilesParameters(includePattern, excludePattern, mode, removeDirectories);
     using(var block = Repository.Monitor.BlockNotifications(RepositoryNotifications.IndexUpdated))
     {
         files = Repository.Accessor.QueryFilesToClean.Invoke(parameters);
     }
     return RestoreFilesToCleanList(files);
 }
예제 #8
0
파일: Status.cs 프로젝트: Kuzq/gitter
 /// <summary>Remove untracked and/or ignored files and (optionally) directories.</summary>
 /// <param name="includePattern">Files to clean.</param>
 /// <param name="excludePattern">Files to save.</param>
 /// <param name="mode">Clean mode.</param>
 /// <param name="removeDirectories"><c>true</c> to remove directories.</param>
 public void Clean(string includePattern, string excludePattern, CleanFilesMode mode, bool removeDirectories)
 {
     var parameters = GetCleanFilesParameters(includePattern, excludePattern, mode, removeDirectories, true);
     try
     {
         using(Repository.Monitor.BlockNotifications(
             RepositoryNotifications.IndexUpdated,
             RepositoryNotifications.WorktreeUpdated))
         {
             Repository.Accessor.CleanFiles.Invoke(parameters);
         }
     }
     finally
     {
         Refresh();
     }
 }