@@ -34,8 +34,23 @@ trait PullRequestService {
34
34
/** OAuth token for drone, needed to cancel builds */
35
35
def droneToken : String
36
36
37
+ /** OAuthed application's "client_id" */
38
+ def githubClientId : String
39
+
40
+ /** OAuthed application's "client_secret" */
41
+ def githubClientSecret : String
42
+
37
43
/** Pull Request HTTP service */
38
44
val prService = HttpService {
45
+ case GET -> Root / " rate" => {
46
+ val client = PooledHttp1Client ()
47
+ for {
48
+ rates <- client.expect(get(rateLimit))(EntityDecoder .text)
49
+ resp <- Ok (rates)
50
+ _ <- client.shutdown
51
+ } yield resp
52
+ }
53
+
39
54
case request @ POST -> Root =>
40
55
val githubEvent =
41
56
request.headers
@@ -68,21 +83,25 @@ trait PullRequestService {
68
83
)
69
84
70
85
private [this ] val githubUrl = " https://api.github.com"
86
+ private [this ] def withGithubSecret (url : String , extras : String * ): String =
87
+ s " $url?client_id= $githubClientId&client_secret= $githubClientSecret" + extras.mkString(" &" , " &" , " " )
88
+
89
+ def rateLimit : String = withGithubSecret(" https://api.github.com/rate_limit" )
71
90
72
91
def claUrl (userName : String ): String =
73
92
s " https://www.lightbend.com/contribute/cla/scala/check/ $userName"
74
93
75
94
def commitsUrl (prNumber : Int ): String =
76
- s " $githubUrl/repos/lampepfl/dotty/pulls/ $prNumber/commits? per_page=100 "
95
+ withGithubSecret( s " $githubUrl/repos/lampepfl/dotty/pulls/ $prNumber/commits " , " per_page=100" )
77
96
78
97
def statusUrl (sha : String ): String =
79
- s " $githubUrl/repos/lampepfl/dotty/statuses/ $sha"
98
+ withGithubSecret( s " $githubUrl/repos/lampepfl/dotty/statuses/ $sha" )
80
99
81
100
def issueCommentsUrl (issueNbr : Int ): String =
82
- s " $githubUrl/repos/lampepfl/dotty/issues/ $issueNbr/comments "
101
+ withGithubSecret( s " $githubUrl/repos/lampepfl/dotty/issues/ $issueNbr/comments " )
83
102
84
103
def reviewUrl (issueNbr : Int ): String =
85
- s " $githubUrl/repos/lampepfl/dotty/pulls/ $issueNbr/reviews "
104
+ withGithubSecret( s " $githubUrl/repos/lampepfl/dotty/pulls/ $issueNbr/reviews " )
86
105
87
106
sealed trait CommitStatus {
88
107
def commit : Commit
0 commit comments