Statistics
| Branch: | Revision:

iof-tools / networkxMiCe / networkx-master / doc / release / contribs.py @ 5cef0f13

History | View | Annotate | Download (1.52 KB)

1
#!/usr/bin/env python
2
# https://github.com/scikit-image/scikit-image/blob/master/doc/release/contribs.py
3
import subprocess
4
import sys
5
import string
6
import shlex
7

    
8
if len(sys.argv) != 2:
9
    print("Usage: ./contributors.py tag-of-previous-release")
10
    sys.exit(-1)
11

    
12
tag = sys.argv[1]
13

    
14
def call(cmd):
15
    return subprocess.check_output(shlex.split(cmd), universal_newlines=True).split('\n')
16

    
17
tag_date = call("git log -n1 --format='%%ci' %s" % tag)[0]
18
print("Release %s was on %s\n" % (tag, tag_date))
19

    
20
merges = call("git log --since='%s' --merges --format='>>>%%B' --reverse" % tag_date)
21
merges = [m for m in merges if m.strip()]
22
merges = '\n'.join(merges).split('>>>')
23
merges = [m.split('\n')[:2] for m in merges]
24
merges = [m for m in merges if len(m) == 2 and m[1].strip()]
25

    
26
num_commits = call("git rev-list %s..HEAD --count" % tag)[0]
27
print("A total of %s changes have been committed.\n" % num_commits)
28

    
29
print("It contained the following %d merges:\n" % len(merges))
30
for (merge, message) in merges:
31
    if merge.startswith('Merge pull request #'):
32
        PR = ' (%s)' % merge.split()[3]
33
    else:
34
        PR = ''
35

    
36
    print('- ' + message + PR)
37

    
38
print("\nMade by the following committers [alphabetical by last name]:\n")
39

    
40
authors = call("git log --since='%s' --format=%%aN" % tag_date)
41
authors = [a.strip() for a in authors if a.strip()]
42

    
43
def key(author):
44
    author = [v for v in author.split() if v[0] in string.ascii_letters]
45
    if len(author) > 0:
46
        return author[-1]
47

    
48
authors = sorted(set(authors), key=key)
49

    
50
for a in authors:
51
    print('- ' + a)