view scripts/shortlog.py @ 8263:f450318e5ff9

celery: change ini template to use sqlite for results 'amqp://' might be good - also for results, but seems to need additional non-trivial setup. And according to https://docs.celeryproject.org/en/3.0/whatsnew-4.0.html#features-removed-for-lack-of-funding it is deprecated. Kallithea only uses Celery results when repos are created or forked and user browsers are reloading pages to poll for completion. amqp seems like unnecessary complexity for that use case. Sqlite does however seem like a minimal but fine solution for the Kallithea use case in most setups.
author Mads Kiilerich <mads@kiilerich.com>
date Fri, 14 Feb 2020 02:25:00 +0100
parents aa6f17a53b49
children 96b43734025f
line wrap: on
line source

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Kallithea script for generating a quick overview of contributors and their
commit counts in a given revision set.
"""
import argparse
import os
from collections import Counter

from . import contributor_data


def main():

    parser = argparse.ArgumentParser(description='Generate a list of committers and commit counts.')
    parser.add_argument('revset',
                        help='revision set specifying the commits to count')
    args = parser.parse_args()

    repo_entries = [
        (contributor_data.name_fixes.get(name) or contributor_data.name_fixes.get(name.rsplit('<', 1)[0].strip()) or name).rsplit('<', 1)[0].strip()
        for name in (line.strip()
         for line in os.popen("""hg log -r '%s' -T '{author}\n'""" % args.revset).readlines())
        ]

    counter = Counter(repo_entries)
    for name, count in counter.most_common():
        if name == '':
            continue
        print('%4s %s' % (count, name))


if __name__ == '__main__':
    main()