@@ -117,17 +117,37 @@ func (receiver *Receiver) processPullRequest(event *github.PullRequestEvent) {
117
117
mentionSymbol = "@"
118
118
}
119
119
if len (handles ) > 0 && ! strings .Contains (* event .PullRequest .Body , "[skip notification]" ) {
120
- body := "Notifying maintainers:\n "
120
+ // GitHub will only notify the first 50 handles in a single comment
121
+ const mentionLimit = 50
122
+ // i counts from 0 to len(handles)
123
+ // Use (i % mentionLimit) to limit each comment to containing
124
+ // at most (mentionLimit) handles
125
+ i := 0
126
+ totalBatches := (len (handles ) + mentionLimit - 1 ) / mentionLimit
127
+ var body string
121
128
for handle , ports := range handles {
129
+ // Increment counter for each handle
130
+ i ++
131
+ // Initialize body if first handle for this batch
132
+ if (i % mentionLimit ) == 1 {
133
+ currentBatch := (i + mentionLimit - 1 ) / mentionLimit
134
+ body = "Notifying maintainers (batch " + strconv .Itoa (currentBatch ) +
135
+ " of " + strconv .Itoa (totalBatches ) + "):\n "
136
+ }
122
137
body += mentionSymbol + handle + " for port " + strings .Join (ports , ", " ) + ".\n "
123
138
err = receiver .githubClient .AddAssignees (owner , repo , number , []string {handle })
124
139
if err != nil {
125
140
log .Println (err )
126
141
}
127
- }
128
- err = receiver .githubClient .CreateComment (owner , repo , number , & body )
129
- if err != nil {
130
- log .Println (err )
142
+ // Create comment if last handle for this batch
143
+ // (either once body contains (mentionLimit) handles,
144
+ // or when there are no handles left)
145
+ if ((i % mentionLimit ) == 0 ) || (i == len (handles )) {
146
+ err = receiver .githubClient .CreateComment (owner , repo , number , & body )
147
+ if err != nil {
148
+ log .Println (err )
149
+ }
150
+ }
131
151
}
132
152
}
133
153
0 commit comments