diff --git a/src/main/resources/update/gitbucket-core_4.27.xml b/src/main/resources/update/gitbucket-core_4.27.xml new file mode 100644 index 000000000..b939f53ec --- /dev/null +++ b/src/main/resources/update/gitbucket-core_4.27.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/main/scala/gitbucket/core/GitBucketCoreModule.scala b/src/main/scala/gitbucket/core/GitBucketCoreModule.scala index 99b0c6e73..c0345f472 100644 --- a/src/main/scala/gitbucket/core/GitBucketCoreModule.scala +++ b/src/main/scala/gitbucket/core/GitBucketCoreModule.scala @@ -55,5 +55,6 @@ object GitBucketCoreModule new Version("4.24.0", new LiquibaseMigration("update/gitbucket-core_4.24.xml")), new Version("4.24.1"), new Version("4.25.0", new LiquibaseMigration("update/gitbucket-core_4.25.xml")), - new Version("4.26.0") + new Version("4.26.0"), + new Version("4.27.0", new LiquibaseMigration("update/gitbucket-core_4.27.xml")) ) diff --git a/src/main/scala/gitbucket/core/model/Comment.scala b/src/main/scala/gitbucket/core/model/Comment.scala index 8e5044cbb..9314b2e90 100644 --- a/src/main/scala/gitbucket/core/model/Comment.scala +++ b/src/main/scala/gitbucket/core/model/Comment.scala @@ -54,6 +54,9 @@ trait CommitCommentComponent extends TemplateComponent { self: Profile => val registeredDate = column[java.util.Date]("REGISTERED_DATE") val updatedDate = column[java.util.Date]("UPDATED_DATE") val issueId = column[Option[Int]]("ISSUE_ID") + val originalCommitId = column[String]("ORIGINAL_COMMIT_ID") + val originalOldLine = column[Option[Int]]("ORIGINAL_OLD_LINE") + val originalNewLine = column[Option[Int]]("ORIGINAL_NEW_LINE") def * = ( userName, @@ -67,7 +70,10 @@ trait CommitCommentComponent extends TemplateComponent { self: Profile => newLine, registeredDate, updatedDate, - issueId + issueId, + originalCommitId, + originalOldLine, + originalNewLine ) <> (CommitComment.tupled, CommitComment.unapply) def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind @@ -86,7 +92,10 @@ case class CommitComment( newLine: Option[Int], registeredDate: java.util.Date, updatedDate: java.util.Date, - issueId: Option[Int] + issueId: Option[Int], + originalCommitId: String, + originalOldLine: Option[Int], + originalNewLine: Option[Int] ) extends Comment case class CommitComments( diff --git a/src/main/scala/gitbucket/core/service/CommitsService.scala b/src/main/scala/gitbucket/core/service/CommitsService.scala index 8f81b760b..b59c9298c 100644 --- a/src/main/scala/gitbucket/core/service/CommitsService.scala +++ b/src/main/scala/gitbucket/core/service/CommitsService.scala @@ -49,7 +49,10 @@ trait CommitsService { newLine = newLine, registeredDate = currentDate, updatedDate = currentDate, - issueId = issueId + issueId = issueId, + originalCommitId = commitId, + originalOldLine = oldLine, + originalNewLine = newLine ) def updateCommitCommentPosition(commentId: Int, commitId: String, oldLine: Option[Int], newLine: Option[Int])( diff --git a/src/main/scala/gitbucket/core/service/PullRequestService.scala b/src/main/scala/gitbucket/core/service/PullRequestService.scala index c6cde8e13..8612d7452 100644 --- a/src/main/scala/gitbucket/core/service/PullRequestService.scala +++ b/src/main/scala/gitbucket/core/service/PullRequestService.scala @@ -181,9 +181,9 @@ trait PullRequestService { self: IssuesService with CommitsService => // Collect comment positions val positions = getCommitComments(pullreq.userName, pullreq.repositoryName, pullreq.commitIdTo, true) .collect { - case CommitComment(_, _, _, commentId, _, _, Some(file), None, Some(newLine), _, _, _) => + case CommitComment(_, _, _, commentId, _, _, Some(file), None, Some(newLine), _, _, _, _, _, _) => (file, commentId, Right(newLine)) - case CommitComment(_, _, _, commentId, _, _, Some(file), Some(oldLine), None, _, _, _) => + case CommitComment(_, _, _, commentId, _, _, Some(file), Some(oldLine), None, _, _, _, _, _, _) => (file, commentId, Left(oldLine)) } .groupBy { case (file, _, _) => file } @@ -348,7 +348,7 @@ trait PullRequestService { self: IssuesService with CommitsService => .groupBy { case x: IssueComment => (Some(x.commentId), None, None, None) case x: CommitComment if x.fileName.isEmpty => (Some(x.commentId), None, None, None) - case x: CommitComment => (None, x.fileName, x.oldLine, x.newLine) + case x: CommitComment => (None, x.fileName, x.originalOldLine, x.originalNewLine) case x => throw new MatchError(x) } .toSeq @@ -366,7 +366,7 @@ trait PullRequestService { self: IssuesService with CommitsService => diff = loadCommitCommentDiff( userName, repositoryName, - comments.head.asInstanceOf[CommitComment].commitId, + comments.head.asInstanceOf[CommitComment].originalCommitId, fileName, oldLine, newLine