Пример #1
0
        public void Add(string filePath, LibGit2Sharp.ChangeKind changeKind, Developer developer, Commit commit, Period period)
        {
            var developerName = developer?.NormalizedName;

            if (filePath == null || developerName == null)
            {
                return;
            }

            if (!_map.ContainsKey(filePath))
            {
                _map[filePath] = new Dictionary <string, DeveloperFileCommitDetail>();
            }

            if (!_map[filePath].ContainsKey(developerName))
            {
                _map[filePath][developerName] = new DeveloperFileCommitDetail()
                {
                    FilePath  = filePath,
                    Developer = developer,
                };
            }

            if (!_map[filePath][developerName].Commits.Any(q => q.Sha == commit?.Sha))
            {
                _map[filePath][developerName].CommitDetails.Add(new CommitDetail(commit, period, changeKind));
                _map[filePath][developerName].Commits.Add(commit);
                UpdateDeveloperCommits(commit, developerName);
            }

            if (!_map[filePath][developerName].Periods.Any(q => q.Id == period.Id))
            {
                _map[filePath][developerName].Periods.Add(period);
            }
        }
Пример #2
0
        private static void AddModificationOwnershipDetail(Dictionary <string, DeveloperKnowledge> developersKnowledge, DeveloperFileCommitDetail developerFileCommitsDetail, int totalAuditedLines)
        {
            var developerName = developerFileCommitsDetail.Developer.NormalizedName;

            if (!developersKnowledge.ContainsKey(developerName))
            {
                developersKnowledge[developerName] = new DeveloperKnowledge()
                {
                    DeveloperName = developerName
                };
            }

            developersKnowledge[developerName].NumberOfCommits       += developerFileCommitsDetail.Commits.Count();
            developersKnowledge[developerName].NumberOfAuthoredLines += totalAuditedLines;

            developersKnowledge[developerName].AddCommittedFile(developerFileCommitsDetail.FilePath);
        }