Пример #1
0
def test(path_to_repo, filepath, from_commit, to_commit, expected):
    metric = CommitsCount(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
Пример #2
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,
     }
Пример #3
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()}
Пример #4
0
def test_with_dates(path_to_repo, filepath, since, to, expected):
    metric = CommitsCount(path_to_repo=path_to_repo, since=since, to=to)
    count = metric.count()
    filepath = str(Path(filepath))
    assert count[filepath] == expected
Пример #5
0
metric = ContributorsCount(
    path_to_repo='G:\\GIT_Repos\\spring-framework',
    from_commit='8119659fb1e4ae6fabe8897c42ba7629fda07b21',
    to_commit='c2f7b6575156a7c3e049e17248acb6b580ba899f')
count = metric.count()
print('Number of contributors per file: {}'.format(count))

# Get Number of lines / each file in the repo directory
metric = LinesCount(path_to_repo="G:\\GIT_Repos\\spring-framework",
                    from_commit='8119659fb1e4ae6fabe8897c42ba7629fda07b21',
                    to_commit='c2f7b6575156a7c3e049e17248acb6b580ba899f')
added_count = metric.count_added()
print(type(added_count))

# Get number of commits / each file in the repo directory
metric = CommitsCount(path_to_repo='G:\\GIT_Repos\\spring-framework',
                      from_commit='8119659fb1e4ae6fabe8897c42ba7629fda07b21',
                      to_commit='c2f7b6575156a7c3e049e17248acb6b580ba899f')
files = metric.count()

f = open("output.txt", "w")
# searching by key and value in dictionary, key means file name, value means actual commits number, etc, value retrieved by build in pydriller functions
for (key, value), (key2, value2), (key3,
                                   value3) in zip(files.items(),
                                                  added_count.items(),
                                                  count.items()):
    f.write('Fisierul cu numele: ' + str(key) + ' are ' + str(value) +
            ' commits, ' + str(value2) + ' linii si ' + str(value3) +
            ' autor(i): ' + '\n')
f.close()