示例#1
0
        private async Task <PrModel> CreatePullRequest(string owner, string repo, int number, string title, string body, string[] userMentions, string author)
        {
            var pr = new PrModel()
            {
                Number       = number,
                Title        = title,
                Description  = body,
                IsPR         = 1,
                Author       = author,
                UserMentions = string.Join(' ', userMentions),
                NumMentions  = userMentions.Length,
            };
            IReadOnlyList <PullRequestFile> prFiles = await _gitHubClientWrapper.GetPullRequestFiles(owner, repo, number);

            if (prFiles.Count != 0)
            {
                string[] filePaths     = prFiles.Select(x => x.FileName).ToArray();
                var      segmentedDiff = _diffHelper.SegmentDiff(filePaths);
                pr.Files          = string.Join(' ', segmentedDiff.FileDiffs);
                pr.Filenames      = string.Join(' ', segmentedDiff.Filenames);
                pr.FileExtensions = string.Join(' ', segmentedDiff.Extensions);
                pr.Folders        = _diffHelper.FlattenWithWhitespace(segmentedDiff.Folders);
                pr.FolderNames    = _diffHelper.FlattenWithWhitespace(segmentedDiff.FolderNames);
                try
                {
                    pr.ShouldAddDoc = await DoesPrAddNewApiAsync(owner, repo, pr.Number);
                }
                catch (Exception ex)
                {
                    _logger.LogInformation("! problem with new approach: " + ex.Message);
                    pr.ShouldAddDoc = segmentedDiff.AddDocInfo;
                }
            }
            pr.FileCount = prFiles.Count;
            return(pr);
        }