Esempio n. 1
0
        public async Task Execute(string repoPath, string branchName)
        {
            using (var dbContext = new GitRepositoryDbContext(false))
            {
                var gitRepository  = new GitRepository(repoPath, _logger);
                var orderedCommits = gitRepository.ExtractCommitsFromBranch(branchName);
                var relationships  = orderedCommits.SelectMany(q => q.CommitRelationship).ToArray();
                _logger.LogInformation("{datetime}: trying to save {count} commits into database.", DateTime.Now, orderedCommits.Count());
                await dbContext.BulkInsertAsync(orderedCommits).ConfigureAwait(false);

                await dbContext.BulkInsertAsync(relationships).ConfigureAwait(false);

                _logger.LogInformation("{datetime}: commits has been saved successfully.", DateTime.Now);
            }
        }
        private async Task ExtractBlamesofCommit(Commit commit, Dictionary <string, string> canonicalDic, string[] validExtensions, string[] excludePath, GitRepository gitRepository, string branch, bool extractBlames)
        {
            using (var dbContext = new GitRepositoryDbContext(false))
            {
                _logger.LogInformation("{datetime}: extracting blames out of commit {Commitsha}", DateTime.Now, commit.Sha);

                gitRepository.LoadBlobsAndTheirBlamesOfCommit(commit, validExtensions, excludePath, canonicalDic, extractBlames, branch);

                var blames = commit.Blobs.SelectMany(m => m.CommitBlobBlames);
                _logger.LogInformation("{datetime}: saving {count} blames of {blobCount} from commit {Commitsha} into database.", DateTime.Now, blames.Count(), commit.Blobs.Count(), commit.Sha);

                await dbContext.BulkInsertAsync(commit.Blobs.ToArray()).ConfigureAwait(false);

                await dbContext.BulkInsertAsync(blames.ToArray()).ConfigureAwait(false);

                _logger.LogInformation("{datetime}: blames of {Commitsha} have been saved.", DateTime.Now, commit.Sha);
            }
        }
        public async Task Execute(string repoPath, string branchName, string[] validExtensions, string[] excludedBlamePaths)
        {
            using (var dbContext = new GitRepositoryDbContext(false))
            {
                var gitRepository    = new GitRepository(repoPath, _logger);
                var committedChanges = dbContext.CommittedChanges.ToArray();

                _logger.LogInformation("{datetime}: just started to extract blames.", DateTime.Now);
                var blames = gitRepository.GetBlameOfChanges(branchName, validExtensions, excludedBlamePaths, committedChanges);
                _logger.LogInformation("{datetime}: trying to save {count} blames into database.", DateTime.Now, blames.Count());
                await dbContext.BulkInsertAsync(blames).ConfigureAwait(false);

                _logger.LogInformation("{datetime}: blames has been saved successfully.", DateTime.Now);
            }
        }