コード例 #1
0
        /// <summary>Generates an issues report against a specific GitHu repo.</summary>
        /// <param name="repo">Description of the repo to generate the repo for.</param>
        /// <param name="outputPath">Path of the directory in which to generate the report.</param>
        /// <param name="issueFormatter">Map of the columns to include in the report. Associates a column name
        /// with a function for extracting the associated data from an issue object.</param>
        /// <returns>A task that represents the work queued to execute.</returns>
        /// <remarks>The task is successful if it queries GitHub and generates the report.</remarks>
        private static async Task GetDocRepoIssues(
            GitHubConstants.RepoParams repo,
            string outputPath,
            Dictionary <string, Func <Issue, string> > issueFormatter)
        {
            Console.Write("Gathering issue data for the docs repo a page at a time");
            var issues = new List <Issue>();

            string queryWithStartCursor(string start) => Requests.GetAllIssues(repo, start);

            await foreach (var sublist in GitHubQlService.GetConnectionAsync(
                               queryWithStartCursor, d => d.Repository.Issues, c => c.Nodes, new CancellationToken()))
            {
                Console.Write(".");
                issues.AddRange(sublist);
            }
            Console.WriteLine("done. ");

            var issueReport = Path.Combine(outputPath, "DocRepoIssues.csv");

            Console.Write($"Writing issue information to '{issueReport}'...");
            using (TextWriter writer = new StreamWriter(issueReport, false))
            {
                writer.WriteLine(string.Join(',', issueFormatter.Keys));
                foreach (var issue in issues)
                {
                    writer.WriteLine(string.Join(',',
                                                 issueFormatter.Values.Select(func => func(issue)?.CsvEscape() ?? string.Empty)));
                }
            }
            Console.WriteLine("done!");
            Console.WriteLine();
        }
コード例 #2
0
        private static async Task GenerateIssuesReport(
            IEnumerable <GitHubConstants.RepoParams> repos,
            Dictionary <string, Func <Issue, string> > issueFormatter,
            string filePath,
            IssueState[] stateFilter = null,
            string[] labelFilter     = null)
        {
            var issues = new List <Issue>();

            foreach (var repo in repos)
            {
                Console.Write($"Gathering issue data for the {repo.Owner}/{repo.Name} repo");
                string queryWithStartCursor(string start) => Requests.GetAllIssues(repo, start, stateFilter, labelFilter);

                await foreach (var sublist in GitHubQlService.GetConnectionAsync(
                                   queryWithStartCursor, d => d.Repository.Issues, c => c.Nodes, new CancellationToken()))
                {
                    Console.Write(".");
                    issues.AddRange(sublist);
                }
                Console.WriteLine("done!");
            }

            Console.Write($"Writing issue information to '{filePath}'...");
            using (TextWriter writer = new StreamWriter(filePath, false))
            {
                writer.WriteLine(string.Join(',', issueFormatter.Keys));
                foreach (var issue in issues)
                {
                    writer.WriteLine(string.Join(',',
                                                 issueFormatter.Values.Select(func => func(issue)?.CsvEscape() ?? string.Empty)));
                }
            }
            Console.WriteLine("done!");
            Console.WriteLine();
        }