Kudu.Core.SourceControl.Git.LibGit2SharpRepository.ListFiles C# (CSharp) Метод

ListFiles() публичный Метод

public ListFiles ( string path, SearchOption searchOption ) : IEnumerable
path string
searchOption SearchOption
Результат IEnumerable
        public IEnumerable<string> ListFiles(string path, SearchOption searchOption, params string[] lookupList)
        {
            path = PathUtilityFactory.Instance.CleanPath(path);

            if (!FileSystemHelpers.IsSubfolder(RepositoryPath, path))
            {
                throw new NotSupportedException("Only paths relative to the repository root path are supported, path provided: '{0}' is not a child folder of '{1}'".FormatCurrentCulture(path, RepositoryPath));
            }

            if (!Directory.Exists(path)) return Enumerable.Empty<string>();

            using (var repo = new LibGit2Sharp.Repository(RepositoryPath))
            {
                var files = repo.Diff.Compare<TreeChanges>(null, DiffTargets.Index, lookupList, compareOptions: new CompareOptions() { IncludeUnmodified = true, Similarity = SimilarityOptions.None })
                                      .Select(d => Path.Combine(repo.Info.WorkingDirectory, d.Path))
                                      .Where(p => p.StartsWith(path, StringComparison.OrdinalIgnoreCase));

                switch (searchOption)
                {
                    case SearchOption.TopDirectoryOnly:
                        files = files.Where(line => !line.Substring(path.Length).TrimStart('\\').Contains('\\'));
                        break;

                    case SearchOption.AllDirectories:
                        break;

                    default:
                        throw new NotSupportedException("Search option {0} is not supported".FormatCurrentCulture(searchOption));
                }
                // Make sure to materialize the list before finalizing repo
                return files.ToList();
            }
        }