@@ -103,6 +103,9 @@ trait PullRequestService {
103
103
def reviewUrl (issueNbr : Int ): String =
104
104
withGithubSecret(s " $githubUrl/repos/lampepfl/dotty/pulls/ $issueNbr/reviews " )
105
105
106
+ def contributorsUrl : String =
107
+ withGithubSecret(" https://api.github.com/repos/lampepfl/dotty/contributors" )
108
+
106
109
sealed trait CommitStatus {
107
110
def commit : Commit
108
111
def isValid : Boolean
@@ -183,6 +186,13 @@ trait PullRequestService {
183
186
.headOption
184
187
}
185
188
189
+ /** Get all contributors from GitHub */
190
+ def getContributors (implicit client : Client ): Task [Set [String ]] =
191
+ for {
192
+ authors <- client.expect(get(contributorsUrl))(jsonOf[List [Author ]])
193
+ logins = authors.map(_.login).flatten
194
+ } yield logins.toSet
195
+
186
196
/** Ordered from earliest to latest */
187
197
def getCommits (issueNbr : Int )(implicit httpClient : Client ): Task [List [Commit ]] = {
188
198
def makeRequest (url : String ): Task [List [Commit ]] =
@@ -299,10 +309,16 @@ trait PullRequestService {
299
309
setStatus(statuses.last, httpClient)
300
310
}
301
311
302
- // Send positive comment:
303
- _ <- sendInitialComment(issue.number, invalidUsers, commits, httpClient)
304
- _ <- httpClient.shutdown
305
- resp <- Ok (" Fresh PR checked" )
312
+ authors = commits.map(_.author.login).flatten.toSet
313
+ contribs <- getContributors
314
+ _ <- {
315
+ if (! authors.forall(contribs.contains))
316
+ sendInitialComment(issue.number, invalidUsers, commits, httpClient)
317
+ else
318
+ Task .now(())
319
+ }
320
+ _ <- httpClient.shutdown
321
+ resp <- Ok (" Fresh PR checked" )
306
322
} yield resp
307
323
308
324
}
0 commit comments