diff --git a/src/main/scala/gitbucket/core/api/ApiPullRequest.scala b/src/main/scala/gitbucket/core/api/ApiPullRequest.scala index 013128f..3ae6ac0 100644 --- a/src/main/scala/gitbucket/core/api/ApiPullRequest.scala +++ b/src/main/scala/gitbucket/core/api/ApiPullRequest.scala @@ -46,17 +46,13 @@ updated_at = issue.updatedDate, created_at = issue.registeredDate, head = Commit( - sha = pullRequest.commitIdTo, - ref = pullRequest.requestBranch, - repo = headRepo, - baseOwner = issue.userName - ), + sha = pullRequest.commitIdTo, + ref = pullRequest.requestBranch, + repo = headRepo)(issue.userName), base = Commit( - sha = pullRequest.commitIdFrom, - ref = pullRequest.branch, - repo = baseRepo, - baseOwner = issue.userName - ), + sha = pullRequest.commitIdFrom, + ref = pullRequest.branch, + repo = baseRepo)(issue.userName), mergeable = None, // TODO: need check mergeable. merged = mergedComment.isDefined, merged_at = mergedComment.map { case (comment, _) => comment.registeredDate }, @@ -69,8 +65,7 @@ case class Commit( sha: String, ref: String, - repo: ApiRepository, - baseOwner:String){ + repo: ApiRepository)(baseOwner:String){ val label = if( baseOwner == repo.owner.login ){ ref }else{ s"${repo.owner.login}:${ref}" } val user = repo.owner } diff --git a/src/test/scala/gitbucket/core/api/JsonFormatSpec.scala b/src/test/scala/gitbucket/core/api/JsonFormatSpec.scala index 6e6376e..0fc254b 100644 --- a/src/test/scala/gitbucket/core/api/JsonFormatSpec.scala +++ b/src/test/scala/gitbucket/core/api/JsonFormatSpec.scala @@ -25,11 +25,11 @@ implicit val context = JsonFormat.Context("http://gitbucket.exmple.com") val apiUser = ApiUser( - login= "octocat", - email= "octocat@example.com", - `type`= "User", - site_admin= false, - created_at= date1) + login = "octocat", + email = "octocat@example.com", + `type` = "User", + site_admin = false, + created_at = date1) val apiUserJson = """{ "login":"octocat", "email":"octocat@example.com", @@ -264,60 +264,64 @@ }""" val apiPullRequest = ApiPullRequest( - number = 1347, - updated_at = date1, - created_at = date1, - head = ApiPullRequest.Commit( - sha = sha1, - ref = "new-topic", - repo = repository)("octocat"), - base = ApiPullRequest.Commit( - sha = sha1, - ref = "master", - repo = repository)("octocat"), - mergeable = None, - title = "new-feature", - body = "Please pull these awesome changes", - user = apiUser - ) + number = 1347, + updated_at = date1, + created_at = date1, + head = ApiPullRequest.Commit( + sha = sha1, + ref = "new-topic", + repo = repository)("octocat"), + base = ApiPullRequest.Commit( + sha = sha1, + ref = "master", + repo = repository)("octocat"), + mergeable = None, + merged = false, + merged_at = Some(date1), + merged_by = Some(apiUser), + title = "new-feature", + body = "Please pull these awesome changes", + user = apiUser + ) + val apiPullRequestJson = s"""{ - "url": "${context.baseUrl}/api/v3/repos/octocat/Hello-World/pulls/1347", + "number": 1347, + "updated_at": "2011-04-14T16:00:49Z", + "created_at": "2011-04-14T16:00:49Z", + // "closed_at": "2011-04-14T16:00:49Z", + "head": { + "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e", + "ref": "new-topic", + "repo": $repositoryJson, + "label": "new-topic", + "user": $apiUserJson + }, + "base": { + "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e", + "ref": "master", + "repo": $repositoryJson, + "label": "master", + "user": $apiUserJson + }, + // "merge_commit_sha": "e5bd3914e2e596debea16f433f57875b5b90bcd6", + // "mergeable": true, + "merged": false, + "merged_at": "2011-04-14T16:00:49Z", + "merged_by": $apiUserJson, + "title": "new-feature", + "body": "Please pull these awesome changes", + "user": $apiUserJson, "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", - // "issue_url": "${context.baseUrl}/api/v3/repos/octocat/Hello-World/issues/1347", + "url": "${context.baseUrl}/api/v3/repos/octocat/Hello-World/pulls/1347", "commits_url": "${context.baseUrl}/api/v3/repos/octocat/Hello-World/pulls/1347/commits", "review_comments_url": "${context.baseUrl}/api/v3/repos/octocat/Hello-World/pulls/1347/comments", "review_comment_url": "${context.baseUrl}/api/v3/repos/octocat/Hello-World/pulls/comments/{number}", "comments_url": "${context.baseUrl}/api/v3/repos/octocat/Hello-World/issues/1347/comments", - "statuses_url": "${context.baseUrl}/api/v3/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e", - "number": 1347, + "statuses_url": "${context.baseUrl}/api/v3/repos/octocat/Hello-World/statuses/6dcb09b5b57875f334f61aebed695e2e4193db5e" + // "diff_url": "${context.baseUrl}/octocat/Hello-World/pull/1347.diff", + // "patch_url": "${context.baseUrl}/octocat/Hello-World/pull/1347.patch", + // "issue_url": "${context.baseUrl}/api/v3/repos/octocat/Hello-World/issues/1347", // "state": "open", - "title": "new-feature", - "body": "Please pull these awesome changes", - "created_at": "2011-04-14T16:00:49Z", - "updated_at": "2011-04-14T16:00:49Z", - // "closed_at": "2011-04-14T16:00:49Z", - // "merged_at": "2011-04-14T16:00:49Z", - "head": { - "label": "new-topic", - "ref": "new-topic", - "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e", - "user": $apiUserJson, - "repo": $repositoryJson - }, - "base": { - "label": "master", - "ref": "master", - "sha": "6dcb09b5b57875f334f61aebed695e2e4193db5e", - "user": $apiUserJson, - "repo": $repositoryJson - }, - "user": $apiUserJson - // "merge_commit_sha": "e5bd3914e2e596debea16f433f57875b5b90bcd6", - // "merged": false, - // "mergeable": true, - // "merged_by": $$apiUserJson, // "comments": 10, // "commits": 3, // "additions": 100,