@@ -18,6 +18,59 @@ def jsonify(self):
1818 return json .dumps (out , separators = (',' , ':' ))
1919
2020
21+ class Approved (Comment ):
22+ def __init__ (self , bot = None , ** args ):
23+ # Because homu needs to leave a comment for itself to kick off a build,
24+ # we need to know the correct botname to use. However, we don't want to
25+ # save that botname in our state JSON. So we need a custom constructor
26+ # to grab the botname and delegate the rest of the keyword args to the
27+ # Comment constructor.
28+ super ().__init__ (** args )
29+ self .bot = bot
30+
31+ params = ["sha" , "approver" ]
32+
33+ def render (self ):
34+ # The comment here is required because Homu wants a full, unambiguous,
35+ # pinned commit hash to kick off the build, and this note-to-self is
36+ # how it gets it. This is to safeguard against situations where Homu
37+ # reloads and another commit has been pushed since the approval.
38+ message = ":pushpin: Commit {sha} has been " + \
39+ "approved by `{approver}`\n \n " + \
40+ "<!-- @{bot} r={approver} {sha} -->"
41+ return message .format (
42+ sha = self .sha ,
43+ approver = self .approver ,
44+ bot = self .bot
45+ )
46+
47+
48+ class ApprovalIgnoredWip (Comment ):
49+ def __init__ (self , wip_keyword = None , ** args ):
50+ # We want to use the wip keyword in the message, but not in the json
51+ # blob.
52+ super ().__init__ (** args )
53+ self .wip_keyword = wip_keyword
54+
55+ params = ["sha" ]
56+
57+ def render (self ):
58+ message = ':clipboard:' + \
59+ ' Looks like this PR is still in progress,' + \
60+ ' ignoring approval.\n \n ' + \
61+ 'Hint: Remove **{wip_keyword}** from this PR\' s title when' + \
62+ ' it is ready for review.'
63+ return message .format (wip_keyword = self .wip_keyword )
64+
65+
66+ class Delegated (Comment ):
67+ params = ["delegator" , "delegate" ]
68+
69+ def render (self ):
70+ message = ':v: @{} can now approve this pull request'
71+ return message .format (self .delegate )
72+
73+
2174class BuildStarted (Comment ):
2275 params = ["head_sha" , "merge_sha" ]
2376
0 commit comments