10
10
"""
11
11
from docutils import nodes
12
12
from docutils .parsers .rst import Directive
13
+ import git
13
14
14
15
from announce import build_components
15
16
@@ -19,17 +20,25 @@ class ContributorsDirective(Directive):
19
20
name = 'contributors'
20
21
21
22
def run (self ):
22
- components = build_components (self .arguments [0 ])
23
-
24
- message = nodes .paragraph ()
25
- message += nodes .Text (components ['author_message' ])
26
-
27
- listnode = nodes .bullet_list ()
28
-
29
- for author in components ['authors' ]:
30
- para = nodes .paragraph ()
31
- para += nodes .Text (author )
32
- listnode += nodes .list_item ('' , para )
23
+ range_ = self .arguments [0 ]
24
+ try :
25
+ components = build_components (range_ )
26
+ except git .GitCommandError :
27
+ return [
28
+ self .state .document .reporter .warning (
29
+ "Cannot find contributors for range '{}'" .format (range_ ),
30
+ line = self .lineno )
31
+ ]
32
+ else :
33
+ message = nodes .paragraph ()
34
+ message += nodes .Text (components ['author_message' ])
35
+
36
+ listnode = nodes .bullet_list ()
37
+
38
+ for author in components ['authors' ]:
39
+ para = nodes .paragraph ()
40
+ para += nodes .Text (author )
41
+ listnode += nodes .list_item ('' , para )
33
42
34
43
return [message , listnode ]
35
44
0 commit comments