diff --git a/src/main/scala/gitbucket/core/api/ApiComment.scala b/src/main/scala/gitbucket/core/api/ApiComment.scala index 9e00e90..62bcd3c 100644 --- a/src/main/scala/gitbucket/core/api/ApiComment.scala +++ b/src/main/scala/gitbucket/core/api/ApiComment.scala @@ -14,8 +14,8 @@ user: ApiUser, body: String, created_at: Date, - updated_at: Date)(repositoryName: RepositoryName, issueId: Int, issueOrPullRequest: IssueOrPullRequest){ - val html_url = ApiPath(s"/${repositoryName.fullName}/${issueOrPullRequest.path}/${issueId}#comment-${id}") + updated_at: Date)(repositoryName: RepositoryName, issueId: Int, isPullRequest: Boolean){ + val html_url = ApiPath(s"/${repositoryName.fullName}/${if(isPullRequest){ "pull" }else{ "issues" }}/${issueId}#comment-${id}") } object ApiComment{ @@ -25,5 +25,5 @@ user = user, body = comment.content, created_at = comment.registeredDate, - updated_at = comment.updatedDate)(repositoryName, issueId, IssueOrPullRequest(isPullRequest)) + updated_at = comment.updatedDate)(repositoryName, issueId, isPullRequest) } diff --git a/src/main/scala/gitbucket/core/api/ApiIssue.scala b/src/main/scala/gitbucket/core/api/ApiIssue.scala index 38c7496..a73a335 100644 --- a/src/main/scala/gitbucket/core/api/ApiIssue.scala +++ b/src/main/scala/gitbucket/core/api/ApiIssue.scala @@ -17,9 +17,9 @@ state: String, created_at: Date, updated_at: Date, - body: String)(repositoryName: RepositoryName, issueOrPullRequest: IssueOrPullRequest){ + 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}/${issueOrPullRequest.path}/${number}") + val html_url = ApiPath(s"/${repositoryName.fullName}/${if(isPullRequest){ "pull" }else{ "issues" }}/${number}") } object ApiIssue{ @@ -31,5 +31,5 @@ state = if(issue.closed){ "closed" }else{ "open" }, body = issue.content.getOrElse(""), created_at = issue.registeredDate, - updated_at = issue.updatedDate)(repositoryName, IssueOrPullRequest(issue.isPullRequest)) + updated_at = issue.updatedDate)(repositoryName, issue.isPullRequest) } diff --git a/src/main/scala/gitbucket/core/api/IssueOrPullRequest.scala b/src/main/scala/gitbucket/core/api/IssueOrPullRequest.scala deleted file mode 100644 index 316ceab..0000000 --- a/src/main/scala/gitbucket/core/api/IssueOrPullRequest.scala +++ /dev/null @@ -1,5 +0,0 @@ -package gitbucket.core.api - -case class IssueOrPullRequest(isPullRequest:Boolean){ - val path = if(isPullRequest){ "pull" }else{ "issues" } -} \ No newline at end of file diff --git a/src/test/scala/gitbucket/core/api/JsonFormatSpec.scala b/src/test/scala/gitbucket/core/api/JsonFormatSpec.scala index c336416..3ff13a6 100644 --- a/src/test/scala/gitbucket/core/api/JsonFormatSpec.scala +++ b/src/test/scala/gitbucket/core/api/JsonFormatSpec.scala @@ -90,7 +90,7 @@ user = apiUser, body= "Me too", created_at= date1, - updated_at= date1)(RepositoryName("octocat","Hello-World"), 100, IssueOrPullRequest(false)) + updated_at= date1)(RepositoryName("octocat","Hello-World"), 100, false) val apiCommentJson = s"""{ "id": 1, "body": "Me too", @@ -105,7 +105,7 @@ user = apiUser, body= "Me too", created_at= date1, - updated_at= date1)(RepositoryName("octocat","Hello-World"), 100, IssueOrPullRequest(true)) + updated_at= date1)(RepositoryName("octocat","Hello-World"), 100, true) val apiCommentPRJson = s"""{ "id": 1, "body": "Me too", @@ -173,7 +173,7 @@ state = "open", body = "I'm having a problem with this.", created_at = date1, - updated_at = date1)(RepositoryName("octocat","Hello-World"), IssueOrPullRequest(false)) + updated_at = date1)(RepositoryName("octocat","Hello-World"), false) val apiIssueJson = s"""{ "number": 1347, "state": "open", @@ -193,7 +193,7 @@ state = "open", body = "I'm having a problem with this.", created_at = date1, - updated_at = date1)(RepositoryName("octocat","Hello-World"), IssueOrPullRequest(true)) + updated_at = date1)(RepositoryName("octocat","Hello-World"), true) val apiIssuePRJson = s"""{ "number": 1347, "state": "open",