forked from tiborsimko/invenio-devscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
invenio-check-AUTHORS
executable file
·63 lines (55 loc) · 2.17 KB
/
invenio-check-AUTHORS
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
#
# Tibor Simko <[email protected]>
#
# Copyright (C) 2011, 2012 CERN.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
"""
A helper devscript to check whether all git committers are well listed
in the AUTHORS or THANKS file. For more information, see
<https://github.com/tiborsimko/invenio-devscripts>.
"""
import commands
import os
import sys
# configuration section:
CFG_INVENIO_SRCDIR = os.environ.get('CFG_INVENIO_SRCDIR',
os.path.join(os.environ.get('HOME'),
'private/src/invenio'))
# list of known false positives, i.e. names that appear in the AUTHORS
# or THANKS file but were spelled differently in some of git commits:
CFG_FALSE_POSITIVES = ['Travis C. Brooks',
'valkyrie',
'Javier Martin Montull']
# go to Invenio source directory:
os.chdir(CFG_INVENIO_SRCDIR)
# detect all git committers:
authors = []
out = commands.getoutput('git log | grep "^Author:" | sort | uniq')
for line in out.split('\n'):
authors.append(line[8:])
# check if they are in AUTHORS or THANKS file:
errors_found = False
for author in authors:
author_name = author.split(' <', 1)[0]
out = commands.getoutput('grep -c "%s" AUTHORS' % author_name)
if out == '0':
out = commands.getoutput('grep -c "%s" THANKS' % author_name)
if out == '0':
if author_name not in CFG_FALSE_POSITIVES:
errors_found = True
print "[ERROR] %s does not seem to be in AUTHORS or THANKS file." % author
if errors_found:
sys.exit(1)