Пример #1
0
 private void UpdatePullRequestEffortKnowledgeMap(IEnumerable <PullRequestReviewerComment> pullRequestReviewComments)
 {
     foreach (var pullRequestReviewComment in pullRequestReviewComments)
     {
         PullRequestEffortKnowledgeMap.Add(
             CanononicalPathMapper.GetValueOrDefault(pullRequestReviewComment.Path),
             UsernameRepository.GetByGitHubLogin(pullRequestReviewComment.UserLogin),
             pullRequestReviewComment.CreatedAtDateTime);
     }
 }
Пример #2
0
        private void UpdateReviewBasedKnowledgeMap(PullRequest pullRequest)
        {
            var reviewers = PullRequestSimulatedRecommendationDic[pullRequest.Number].SelectedReviewers
                            .Where(q => !_megaDevelopersSet.Contains(q)).Select(reviewerName => DevelopersDic[reviewerName]);
            var period = GetPeriodOfPullRequest(pullRequest);

            // some of the pull requests have no modified files strangely
            // for example, https://github.com/dotnet/coreclr/pull/13534
            foreach (var file in PullRequestFilesDic.GetValueOrDefault(pullRequest.Number, _emptyPullRequestFiles))
            {
                var canonicalPath = CanononicalPathMapper.GetValueOrDefault(file.FileName);
                ReviewBasedKnowledgeMap.Add(canonicalPath, reviewers, pullRequest, period);
            }
        }
Пример #3
0
        private Dictionary <long, List <PullRequestFile> > GetPullRequestFilesDictionary(PullRequestFile[] pullRequestFiles)
        {
            var result = new Dictionary <long, List <PullRequestFile> >();
            var key    = 0L;

            for (var i = 0; i < pullRequestFiles.Length; i++)
            {
                // we remove this file, if there it is not recorded in the committedchanges dataset
                if (!CanononicalPathMapper.ContainsKey(pullRequestFiles[i].FileName))
                {
                    continue;
                }

                key = pullRequestFiles[i].PullRequestNumber;
                if (!result.ContainsKey(key))
                {
                    result[key] = new List <PullRequestFile>();
                }

                result[key].Add(pullRequestFiles[i]);
            }

            return(result);
        }
Пример #4
0
        private void AddProposedChangesToPrSubmitterKnowledge(PullRequest pullRequest)
        {
            // we assume the PR submitter is the dev who has modified the files
            // however it's not the case always. for example https://github.com/dotnet/coreclr/pull/1
            // we assume all the proposed file changes are committed and owned by the main pull request's author
            // which may not be correct in rare scenarios

            if (pullRequest == null)
            {
                return;
            }

            var submitter = UsernameRepository.GetByGitHubLogin(pullRequest.UserLogin);

            // we have ignored mega developers
            if (submitter == null || _megaDevelopersSet.Contains(submitter.NormalizedName))
            {
                return;
            }

            // some of the pull requests have no modified files
            // https://github.com/dotnet/coreclr/pull/13534
            var pullRequestFiles = PullRequestFilesDic.GetValueOrDefault(pullRequest.Number, new List <PullRequestFile>());

            var prSubmitter = submitter.NormalizedName;

            var period = GetPeriodOfPullRequest(pullRequest);

            foreach (var file in pullRequestFiles)
            {
                var canonicalPath = CanononicalPathMapper.GetValueOrDefault(file.FileName);
                AssignKnowledgeToDeveloper(new Commit {
                    NormalizedAuthorName = prSubmitter, PeriodId = period.Id, Sha = pullRequest.MergeCommitSha, AuthorDateTime = pullRequest.MergedAtDateTime.Value
                }, file.ChangeKind, prSubmitter, period, canonicalPath);
            }
        }