diff --git a/src/main/resources/update/3_9.sql b/src/main/resources/update/3_9.sql index ec2ecf1..b2f5c56 100644 --- a/src/main/resources/update/3_9.sql +++ b/src/main/resources/update/3_9.sql @@ -41,3 +41,15 @@ GROUP BY USER_NAME, REPOSITORY_NAME, ISSUE_ID ) C ON (A.USER_NAME = C.USER_NAME AND A.REPOSITORY_NAME = C.REPOSITORY_NAME AND A.ISSUE_ID = C.ISSUE_ID); + + +UPDATE COMMIT_COMMENT C SET (ISSUE_ID) = ( + SELECT MAX(P.ISSUE_ID) + FROM PULL_REQUEST P + WHERE + C.USER_NAME = P.USER_NAME AND + C.REPOSITORY_NAME = P.REPOSITORY_NAME AND + C.COMMIT_ID = P.COMMIT_ID_TO +); + +ALTER TABLE COMMIT_COMMENT DROP COLUMN PULL_REQUEST; \ No newline at end of file diff --git a/src/main/scala/gitbucket/core/model/Comment.scala b/src/main/scala/gitbucket/core/model/Comment.scala index ffe2c01..cab001c 100644 --- a/src/main/scala/gitbucket/core/model/Comment.scala +++ b/src/main/scala/gitbucket/core/model/Comment.scala @@ -55,9 +55,8 @@ val newLine = column[Option[Int]]("NEW_LINE_NUMBER") val registeredDate = column[java.util.Date]("REGISTERED_DATE") val updatedDate = column[java.util.Date]("UPDATED_DATE") - val pullRequest = column[Boolean]("PULL_REQUEST") val issueId = column[Option[Int]]("ISSUE_ID") - def * = (userName, repositoryName, commitId, commentId, commentedUserName, content, fileName, oldLine, newLine, registeredDate, updatedDate, pullRequest, issueId) <> (CommitComment.tupled, CommitComment.unapply) + def * = (userName, repositoryName, commitId, commentId, commentedUserName, content, fileName, oldLine, newLine, registeredDate, updatedDate, issueId) <> (CommitComment.tupled, CommitComment.unapply) def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind } @@ -75,6 +74,5 @@ newLine: Option[Int], registeredDate: java.util.Date, updatedDate: java.util.Date, - pullRequest: Boolean, issueId: Option[Int] ) extends Comment diff --git a/src/main/scala/gitbucket/core/service/CommitsService.scala b/src/main/scala/gitbucket/core/service/CommitsService.scala index 45219f1..5ccffd5 100644 --- a/src/main/scala/gitbucket/core/service/CommitsService.scala +++ b/src/main/scala/gitbucket/core/service/CommitsService.scala @@ -13,9 +13,9 @@ trait CommitsService { - def getCommitComments(owner: String, repository: String, commitId: String, pullRequest: Boolean)(implicit s: Session) = + def getCommitComments(owner: String, repository: String, commitId: String, includePullRequest: Boolean)(implicit s: Session) = CommitComments filter { - t => t.byCommit(owner, repository, commitId) && (t.pullRequest === pullRequest || pullRequest) + t => t.byCommit(owner, repository, commitId) && (t.issueId.isEmpty || includePullRequest) } list def getCommitComment(owner: String, repository: String, commentId: String)(implicit s: Session) = @@ -40,7 +40,6 @@ newLine = newLine, registeredDate = currentDate, updatedDate = currentDate, - pullRequest = issueId.isDefined, issueId = issueId) def updateCommitComment(commentId: Int, content: String)(implicit s: Session) = diff --git a/src/main/twirl/gitbucket/core/helper/commitcomment.scala.html b/src/main/twirl/gitbucket/core/helper/commitcomment.scala.html index bc5c531..b35c6d3 100644 --- a/src/main/twirl/gitbucket/core/helper/commitcomment.scala.html +++ b/src/main/twirl/gitbucket/core/helper/commitcomment.scala.html @@ -15,9 +15,9 @@ @user(comment.commentedUserName, styleClass="username strong") commented - @if(comment.pullRequest){ + @if(comment.issueId.isDefined){ on this Pull Request - }else{ + } else { @if(comment.fileName.isDefined){ on @comment.fileName.get }