@@ -63,14 +63,17 @@ trait PullRequestService {
63
63
def statusUrl (sha : String ): String =
64
64
s " https://api.github.com/repos/lampepfl/dotty/statuses/ $sha"
65
65
66
+ def issueCommentsUrl (issueNbr : Int ): String =
67
+ s " https://api.github.com/repos/lampepfl/dotty/issues/ $issueNbr/comments "
68
+
66
69
def toUri (url : String ): Task [Uri ] =
67
70
Uri .fromString(url).fold(Task .fail, Task .now)
68
71
69
- def getRequest (endpoint : Uri ): Request =
70
- Request (uri = endpoint, method = Method .GET ).putHeaders(authHeader)
72
+ def getRequest (endpoint : Uri ): Task [ Request ] =
73
+ Request (uri = endpoint, method = Method .GET ).putHeaders(authHeader).pure[ Task ]
71
74
72
- def postRequest (endpoint : Uri ): Request =
73
- Request (uri = endpoint, method = Method .POST ).putHeaders(authHeader)
75
+ def postRequest (endpoint : Uri ): Task [ Request ] =
76
+ Request (uri = endpoint, method = Method .POST ).putHeaders(authHeader).pure[ Task ]
74
77
75
78
def shutdownClient (client : Client ): Unit =
76
79
client.shutdownNow()
@@ -89,7 +92,7 @@ trait PullRequestService {
89
92
def checkUser (user : String ): Task [Commit => CommitStatus ] = {
90
93
val claStatus = for {
91
94
endpoint <- toUri(claUrl(user))
92
- claReq <- getRequest(endpoint).pure[ Task ]
95
+ claReq <- getRequest(endpoint)
93
96
claRes <- httpClient.expect(claReq)(jsonOf[CLASignature ])
94
97
} yield { (commit : Commit ) =>
95
98
if (claRes.signed) Valid (user, commit)
@@ -133,7 +136,7 @@ trait PullRequestService {
133
136
134
137
for {
135
138
endpoint <- toUri(statusUrl(cm.commit.sha))
136
- req <- postRequest(endpoint).withBody(stat.asJson).pure[ Task ]
139
+ req <- postRequest(endpoint).withBody(stat.asJson)
137
140
res <- httpClient.expect(req)(jsonOf[StatusResponse ])
138
141
} yield res
139
142
}
@@ -158,7 +161,7 @@ trait PullRequestService {
158
161
def makeRequest (url : String ): Task [List [Commit ]] =
159
162
for {
160
163
endpoint <- toUri(url)
161
- req <- getRequest(endpoint).pure[ Task ]
164
+ req <- getRequest(endpoint)
162
165
res <- httpClient.fetch(req){ res =>
163
166
val link = CaseInsensitiveString (" Link" )
164
167
val next = findNext(res.headers.get(link)).map(makeRequest).getOrElse(Task .now(Nil ))
@@ -170,6 +173,13 @@ trait PullRequestService {
170
173
makeRequest(commitsUrl(issueNbr))
171
174
}
172
175
176
+ def getComments (issueNbr : Int , httpClient : Client ): Task [List [Comment ]] =
177
+ for {
178
+ endpoint <- toUri(issueCommentsUrl(issueNbr))
179
+ req <- getRequest(endpoint)
180
+ res <- httpClient.expect(req)(jsonOf[List [Comment ]])
181
+ } yield res
182
+
173
183
def checkPullRequest (issue : Issue ): Task [Response ] = {
174
184
val httpClient = PooledHttp1Client ()
175
185
0 commit comments