Add pull_request key in list issues api if an issue is a pull request

This commit is contained in:
distkloc
2016-03-10 02:08:09 +09:00
parent 70e2079c7f
commit a82e579d57
2 changed files with 16 additions and 0 deletions

View File

@@ -20,6 +20,16 @@ case class ApiIssue(
body: String)(repositoryName: RepositoryName, isPullRequest: Boolean){
val comments_url = ApiPath(s"/api/v3/repos/${repositoryName.fullName}/issues/${number}/comments")
val html_url = ApiPath(s"/${repositoryName.fullName}/${if(isPullRequest){ "pull" }else{ "issues" }}/${number}")
val pull_request = if (isPullRequest) {
Some(Map(
"url" -> ApiPath(s"/api/v3/repos/${repositoryName.fullName}/pulls/${number}"),
"html_url" -> ApiPath(s"/${repositoryName.fullName}/pull/${number}")
// "diff_url" -> ApiPath(s"/${repositoryName.fullName}/pull/${number}.diff"),
// "patch_url" -> ApiPath(s"/${repositoryName.fullName}/pull/${number}.patch")
))
} else {
None
}
}
object ApiIssue{

View File

@@ -252,6 +252,12 @@ class JsonFormatSpec extends FunSuite {
"user": $apiUserJson,
"comments_url": "${context.baseUrl}/api/v3/repos/octocat/Hello-World/issues/1347/comments",
"html_url": "${context.baseUrl}/octocat/Hello-World/pull/1347",
"pull_request": {
"url": "${context.baseUrl}/api/v3/repos/octocat/Hello-World/pulls/1347",
"html_url": "${context.baseUrl}/octocat/Hello-World/pull/1347"
// "diff_url": "${context.baseUrl}/octocat/Hello-World/pull/1347.diff",
// "patch_url": "${context.baseUrl}/octocat/Hello-World/pull/1347.patch"
},
"created_at": "2011-04-14T16:00:49Z",
"updated_at": "2011-04-14T16:00:49Z"
}"""