-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerate_authors.py
More file actions
33 lines (26 loc) · 814 Bytes
/
generate_authors.py
File metadata and controls
33 lines (26 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# -*- coding: utf-8
import os
from optparse import OptionParser
from subprocess import Popen, PIPE
def generate_authors(repo_path):
"""
Generate list of authors using 'git shortlog -n -s'
:param repo_path: string path to directory
:return: None. Prints out the list.
"""
child = Popen(
['git', 'shortlog', '-n', '-s'],
cwd=os.path.expanduser(repo_path),
stdout=PIPE)
for line in child.stdout:
if line:
line = line.strip()
commits, name = line.split(None, 1)
print "* {0}".format(name)
def main():
parser = OptionParser()
parser.add_option("-r", "--repo", dest="repo", help="Repository location")
opts, args = parser.parse_args()
generate_authors(opts.repo)
if __name__ == '__main__':
main()