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 0000000..b939f53 --- /dev/null +++ b/src/main/resources/update/gitbucket-core_4.27.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<changeSet> + <addColumn tableName="COMMIT_COMMENT"> + <column name="ORIGINAL_COMMIT_ID" type="varchar(100)" nullable="true"/> + <column name="ORIGINAL_OLD_LINE" type="int" nullable="true"/> + <column name="ORIGINAL_NEW_LINE" type="int" nullable="true"/> + </addColumn> + <update tableName="COMMIT_COMMENT"> + <column name="ORIGINAL_COMMIT_ID" valueComputed="COMMIT_ID"/> + <column name="ORIGINAL_OLD_LINE" valueComputed="OLD_LINE_NUMBER"/> + <column name="ORIGINAL_NEW_LINE" valueComputed="NEW_LINE_NUMBER"/> + </update> + <addNotNullConstraint columnName="ORIGINAL_COMMIT_ID" tableName="COMMIT_COMMENT" columnDataType="varchar(100)"/> +</changeSet> diff --git a/src/main/scala/gitbucket/core/GitBucketCoreModule.scala b/src/main/scala/gitbucket/core/GitBucketCoreModule.scala index 99b0c6e..c0345f4 100644 --- a/src/main/scala/gitbucket/core/GitBucketCoreModule.scala +++ b/src/main/scala/gitbucket/core/GitBucketCoreModule.scala @@ -55,5 +55,6 @@ 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 8e5044c..9314b2e 100644 --- a/src/main/scala/gitbucket/core/model/Comment.scala +++ b/src/main/scala/gitbucket/core/model/Comment.scala @@ -54,6 +54,9 @@ 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 @@ newLine, registeredDate, updatedDate, - issueId + issueId, + originalCommitId, + originalOldLine, + originalNewLine ) <> (CommitComment.tupled, CommitComment.unapply) def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind @@ -86,7 +92,10 @@ 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 8f81b76..b59c929 100644 --- a/src/main/scala/gitbucket/core/service/CommitsService.scala +++ b/src/main/scala/gitbucket/core/service/CommitsService.scala @@ -49,7 +49,10 @@ 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 c6cde8e..8612d74 100644 --- a/src/main/scala/gitbucket/core/service/PullRequestService.scala +++ b/src/main/scala/gitbucket/core/service/PullRequestService.scala @@ -181,9 +181,9 @@ // 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 @@ .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 @@ diff = loadCommitCommentDiff( userName, repositoryName, - comments.head.asInstanceOf[CommitComment].commitId, + comments.head.asInstanceOf[CommitComment].originalCommitId, fileName, oldLine, newLine