private IEnumerable <FilePattern> ValidateDiffIgnoreFiles(IEnumerable <string> diffIgnoreFiles) { var mappedDiffIgnoreFiles = new List <FilePattern>(); if (diffIgnoreFiles != null) { foreach (var pattern in diffIgnoreFiles) { mappedDiffIgnoreFiles.Add(FilePattern.Parse(FilePathUtils.NormalizePathSeparators(pattern))); } } return(mappedDiffIgnoreFiles); }
private IEnumerable <FilePattern> ValidateFilePatterns(string[] filePatterns, string[] filesToExclude) { var filesToInclude = new List <FilePattern>(); filePatterns ??= Array.Empty <string>(); filesToExclude ??= Array.Empty <string>(); if (!filePatterns.Any()) { // If there are no patterns provided use a pattern that matches every file. filesToInclude.Add(FilePattern.Parse("**/*")); } foreach (var fileToExclude in filesToExclude) { // To support the legacy filesToExclude argument we add an exclude rule for each file exclude. // The files-to-exclude allowed to specify folders and relative paths. var path = fileToExclude; if (!Path.HasExtension(path)) { // Folder exclude path = Path.Combine(path, "*.*"); } // Remove relative path anchors if (path.StartsWith(".\\") || path.StartsWith("./")) { path = path.Remove(0, 2); } filesToInclude.Add(FilePattern.Parse("!" + path)); } foreach (var includePattern in filePatterns) { filesToInclude.Add(FilePattern.Parse(FilePathUtils.NormalizePathSeparators(includePattern))); } if (filesToInclude.All(f => f.IsExclude)) { // If there are only exclude patterns, we add a pattern that matches every file. filesToInclude.Add(FilePattern.Parse("**/*")); } return(filesToInclude); }
protected bool Equals(FilePattern other) { return(Glob.ToString() == other.Glob.ToString() && IsExclude == other.IsExclude && TextSpans.SequenceEqual(other.TextSpans)); }