def test_with_dates(path_to_repo, filepath, since, to, expected_count, expected_max, expected_avg): metric = LinesCount(path_to_repo=path_to_repo, since=since, to=to) actual_count = metric.count_removed() actual_max = metric.max_removed() actual_avg = metric.avg_removed() filepath = str(Path(filepath)) assert actual_count[filepath] == expected_count assert actual_max[filepath] == expected_max assert actual_avg[filepath] == expected_avg
def test_with_commits(path_to_repo, filepath, from_commit, to_commit, expected_count, expected_max, expected_avg): metric = LinesCount(path_to_repo=path_to_repo, from_commit=from_commit, to_commit=to_commit) actual_count = metric.count_removed() actual_max = metric.max_removed() actual_avg = metric.avg_removed() filepath = str(Path(filepath)) assert actual_count[filepath] == expected_count assert actual_max[filepath] == expected_max assert actual_avg[filepath] == expected_avg
def get_process_metrics(self, from_commit: str, to_commit: str) -> dict: """ Extract process metrics for an evolution period. Parameters ---------- from_commit : str Hash of release start to_commit : str Hash of release end """ change_set = ChangeSet(self.path_to_repo, from_commit=from_commit, to_commit=to_commit) code_churn = CodeChurn(self.path_to_repo, from_commit=from_commit, to_commit=to_commit, ignore_added_files=True) commits_count = CommitsCount(self.path_to_repo, from_commit=from_commit, to_commit=to_commit) contributors_count = ContributorsCount(self.path_to_repo, from_commit=from_commit, to_commit=to_commit) highest_contributors_experience = ContributorsExperience(self.path_to_repo, from_commit=from_commit, to_commit=to_commit) median_hunks_count = HunksCount(self.path_to_repo, from_commit=from_commit, to_commit=to_commit) lines_count = LinesCount(self.path_to_repo, from_commit=from_commit, to_commit=to_commit) return { 'dict_change_set_max': change_set.max(), 'dict_change_set_avg': change_set.avg(), 'dict_code_churn_count': code_churn.count(), 'dict_code_churn_max': code_churn.max(), 'dict_code_churn_avg': code_churn.avg(), 'dict_commits_count': commits_count.count(), 'dict_contributors_count': contributors_count.count(), 'dict_minor_contributors_count': contributors_count.count_minor(), 'dict_highest_contributor_experience': highest_contributors_experience.count(), 'dict_hunks_median': median_hunks_count.count(), 'dict_additions': lines_count.count_added(), 'dict_additions_max': lines_count.max_added(), 'dict_additions_avg': lines_count.avg_added(), 'dict_deletions': lines_count.count_removed(), 'dict_deletions_max': lines_count.max_removed(), 'dict_deletions_avg': lines_count.avg_removed()}