/// <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(); } }
/// <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)); }
/// <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)); }
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, }); }
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, }; }
/// <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); }
/// <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); }
/// <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(); } }