Beispiel #1
0
def count_edited_lines_of_code_and_stability_by_author(
        numstat: List[Numstat], blame: List[Blame],
        file_types: List[FileType]) -> List[List]:
    """
    :param numstat: result of :func: git_log_numstat_no_merge
    :param blame:result of :func: git_blame
    :param file_types: list of file types
    :return: list of [author, eloc, stability]
    """
    logging.info(
        "counting edited lines of code and stability by author for [%s]",
        ", ".join(map(str, file_types)))

    blame = list(
        filter(lambda x: FileType.any_match(file_types, x.file) and x.content,
               blame))
    edited_lines_of_code_by_author = __count_by_attr(blame, "author")

    numstat = list(
        filter(lambda x: FileType.any_match(file_types, x.file), numstat))
    insertions_by_author = aggregate_and_sum(numstat, "author", "insertions")

    author_eloc_stability = list()
    for author in insertions_by_author.keys():
        eloc = edited_lines_of_code_by_author[author]
        insertions = insertions_by_author[author]
        stability = float("{:.2f}".format(100 * eloc / insertions))
        author_eloc_stability.append([author, eloc, stability])
    return sorted(author_eloc_stability, key=second_column, reverse=True)
Beispiel #2
0
def count_merges_by_author() -> List[List]:
    """
    :return: list of [author, merges]
    """
    logging.info("executing %s", GIT_SHORTLOG_MERGES)
    raw_short_logs = process.execute(GIT_SHORTLOG_MERGES).split("\n")
    logging.info("counting merges by author")
    short_logs = __raw_short_logs_to_short_logs(raw_short_logs)
    merges_by_author = aggregate_and_sum(short_logs, "author", "commits")
    author_merges = map(list, merges_by_author.items())
    return sorted(author_merges, key=second_column, reverse=True)
Beispiel #3
0
def count_commits_and_impacts_by_author(numstat: List[Numstat]) -> List[List]:
    """
    :param numstat: result of :func: git_log_numstat_no_merge
    :return: list of [author, commits, insertions, deletions]
    """
    logging.info("counting commits and impacts by author")
    insertions_by_author = aggregate_and_sum(numstat, "author", "insertions")
    deletions_by_author = aggregate_and_sum(numstat, "author", "deletions")
    numstat = __unique_by(numstat, "hash")
    commits_by_author = __count_by_attr(numstat, "author")

    author_commits_insertions_deletions = list()
    for author in sorted(insertions_by_author.keys()):
        commits = commits_by_author[author]
        insertions = insertions_by_author[author]
        deletions = deletions_by_author[author]
        author_commits_insertions_deletions.append(
            [author, commits, insertions, deletions])

    return sorted(author_commits_insertions_deletions,
                  key=second_column,
                  reverse=True)
Beispiel #4
0
def count_deletion_ratio_by_author(numstat: List[Numstat],
                                   file_types: List[FileType]) -> List[List]:
    """
    :param numstat: result of :func: git_log_numstat_no_merge
    :param file_types: list of file types
    :return: list of [author, deletion_ratio]
    """
    logging.info("counting deletion ratio by author")
    numstat = list(
        filter(lambda n: FileType.any_match(file_types, n.file), numstat))
    deletions_by_author = aggregate_and_sum(numstat, "author", "deletions")
    numstat = __unique_by(numstat, "hash")
    commits_by_author = __count_by_attr(numstat, "author")

    author_deletion_ratio = list()
    for author in commits_by_author.keys():
        deletion_ratio = deletions_by_author[author] / commits_by_author[author]
        author_deletion_ratio.append([author, deletion_ratio])
    return sorted(author_deletion_ratio, key=second_column, reverse=True)