def test(path_to_repo, filepath, from_commit, to_commit, expected):
    metric = ContributorsExperience(path_to_repo=path_to_repo,
                                    from_commit=from_commit,
                                    to_commit=to_commit)
    count = metric.count()
    filepath = str(Path(filepath))
    assert count[filepath] == expected
def test_with_dates(path_to_repo, filepath, since, to, expected):
    metric = ContributorsExperience(path_to_repo=path_to_repo,
                                    since=since,
                                    to=to)
    count = metric.count()
    filepath = str(Path(filepath))
    assert count[filepath] == expected
Exemplo n.º 3
0
 def fetch_metrics(self):
     change_set = ChangeSet(self.url,
                            since=datetime.datetime.fromtimestamp(0),
                            to=datetime.datetime.now())
     code_churn = CodeChurn(self.url,
                            since=datetime.datetime.fromtimestamp(0),
                            to=datetime.datetime.now())
     commits_count = CommitsCount(self.url,
                                  since=datetime.datetime.fromtimestamp(0),
                                  to=datetime.datetime.now())
     contributors_count = ContributorsCount(
         self.url,
         since=datetime.datetime.fromtimestamp(0),
         to=datetime.datetime.now())
     contributors_experience = ContributorsExperience(
         self.url,
         since=datetime.datetime.fromtimestamp(0),
         to=datetime.datetime.now())
     hunks_count = HunksCount(self.url,
                              since=datetime.datetime.fromtimestamp(0),
                              to=datetime.datetime.now())
     line_count = LinesCount(self.url,
                             since=datetime.datetime.fromtimestamp(0),
                             to=datetime.datetime.now())
     return {
         'changeSet': change_set,
         'codeChurn': code_churn,
         'commitsCount': commits_count,
         'contributorsCount': contributors_count,
         'contributorsExperience': contributors_experience,
         'hunksCount': hunks_count,
         'lineCount': line_count,
     }
Exemplo n.º 4
0
    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()}