9
9
def decommify (name ):
10
10
return ' ' .join (name .split (', ' )[::- 1 ])
11
11
12
+
12
13
# Users who have asked not to be cited at this time
13
14
# XXX We should add a shortlog since the most recent tag and explicitly note
14
15
# that a blacklisted user has contributed again recently, and verify they still
15
16
# do not want to be cited.
16
- blacklist = {'Cecile Madjar' , 'Matthew Wardrop' , 'Peter Van Dyken' , 'github-actions[bot]' }
17
+ blacklist = {
18
+ 'Cecile Madjar' ,
19
+ 'Matthew Wardrop' ,
20
+ 'Peter Van Dyken' ,
21
+ 'github-actions[bot]' ,
22
+ 'dependabot[bot]' ,
23
+ }
17
24
18
25
# List of repositories whose commits should be counted as contributions
19
26
codependents = [('https://github.com/grabbles/grabbit.git' , '0.2.6' )]
@@ -27,12 +34,16 @@ def decommify(name):
27
34
zenodo = json .loads (zenodo_file .read_text ()) if zenodo_file .exists () else {}
28
35
29
36
orig_creators = zenodo .get ('creators' , [])
30
- creator_map = {decommify (creator ['name' ]): creator
31
- for creator in orig_creators }
37
+ creator_map = {
38
+ decommify (creator ['name' ]): creator for creator in orig_creators
39
+ }
32
40
33
41
shortlog = run (['git' , 'shortlog' , '-ns' , f'{ origin_commit } ..' ], stdout = PIPE )
34
- counts = [line .split ('\t ' , 1 )[::- 1 ]
35
- for line in shortlog .stdout .decode ().split ('\n ' ) if line ]
42
+ counts = [
43
+ line .split ('\t ' , 1 )[::- 1 ]
44
+ for line in shortlog .stdout .decode ().split ('\n ' )
45
+ if line
46
+ ]
36
47
37
48
# Get additional commit counts from dependencies
38
49
with TemporaryDirectory () as tmpdir :
@@ -46,19 +57,21 @@ def decommify(name):
46
57
try :
47
58
clone = run (['git' , 'clone' , '-q' , repo , repo_dir ], check = True )
48
59
except CalledProcessError as err :
49
- raise RuntimeError (" Could not clone {}" . format ( repo ) ) from err
60
+ raise RuntimeError (f' Could not clone { repo } ' ) from err
50
61
51
62
if ref is None :
52
63
tag = run (['git' , '-C' , repo_dir , 'tag' ], stdout = PIPE )
53
64
# latest tag
54
65
ref = tag .stdout .decode ().strip ().rsplit ('\n ' , 1 )[1 ]
55
66
56
67
dep_shortlog = run (
57
- ['git' , '-C' , repo_dir , 'shortlog' , '-ns' , ref ],
58
- stdout = PIPE )
59
- counts .extend (line .split ('\t ' , 1 )[::- 1 ]
60
- for line in dep_shortlog .stdout .decode ().split ('\n ' )
61
- if line )
68
+ ['git' , '-C' , repo_dir , 'shortlog' , '-ns' , ref ], stdout = PIPE
69
+ )
70
+ counts .extend (
71
+ line .split ('\t ' , 1 )[::- 1 ]
72
+ for line in dep_shortlog .stdout .decode ().split ('\n ' )
73
+ if line
74
+ )
62
75
63
76
commit_counts = {}
64
77
for committer , commits in counts :
@@ -67,9 +80,12 @@ def decommify(name):
67
80
# Stable sort:
68
81
# Number of commits in reverse order
69
82
# Ties broken by alphabetical order of first name
70
- committers = [committer
71
- for committer , _ in sorted (commit_counts .items (),
72
- key = lambda x : (- x [1 ], x [0 ]))]
83
+ committers = [
84
+ committer
85
+ for committer , _ in sorted (
86
+ commit_counts .items (), key = lambda x : (- x [1 ], x [0 ])
87
+ )
88
+ ]
73
89
74
90
# Tal to the top
75
91
first_author = 'Tal Yarkoni'
@@ -81,7 +97,7 @@ def decommify(name):
81
97
creator_map .get (committer , {'name' : committer })
82
98
for committer in committers
83
99
if committer not in blacklist
84
- ]
100
+ ]
85
101
86
102
zenodo ['creators' ] = creators
87
103
zenodo_file .write_text (json .dumps (zenodo , indent = 2 , ensure_ascii = False ) + '\n ' )
0 commit comments