Merge pull request #2114 from gitbucket/fix-pullreq-comments

Keep pull request comment diff after new commits are pushed
This commit is contained in:
Naoki Takezoe
2018-07-23 01:07:24 +09:00
committed by GitHub
5 changed files with 35 additions and 8 deletions

View File

@@ -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>

View File

@@ -55,5 +55,6 @@ object GitBucketCoreModule
new Version("4.24.0", new LiquibaseMigration("update/gitbucket-core_4.24.xml")), new Version("4.24.0", new LiquibaseMigration("update/gitbucket-core_4.24.xml")),
new Version("4.24.1"), new Version("4.24.1"),
new Version("4.25.0", new LiquibaseMigration("update/gitbucket-core_4.25.xml")), 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"))
) )

View File

@@ -54,6 +54,9 @@ trait CommitCommentComponent extends TemplateComponent { self: Profile =>
val registeredDate = column[java.util.Date]("REGISTERED_DATE") val registeredDate = column[java.util.Date]("REGISTERED_DATE")
val updatedDate = column[java.util.Date]("UPDATED_DATE") val updatedDate = column[java.util.Date]("UPDATED_DATE")
val issueId = column[Option[Int]]("ISSUE_ID") 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 * = def * =
( (
userName, userName,
@@ -67,7 +70,10 @@ trait CommitCommentComponent extends TemplateComponent { self: Profile =>
newLine, newLine,
registeredDate, registeredDate,
updatedDate, updatedDate,
issueId issueId,
originalCommitId,
originalOldLine,
originalNewLine
) <> (CommitComment.tupled, CommitComment.unapply) ) <> (CommitComment.tupled, CommitComment.unapply)
def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind def byPrimaryKey(commentId: Int) = this.commentId === commentId.bind
@@ -86,7 +92,10 @@ case class CommitComment(
newLine: Option[Int], newLine: Option[Int],
registeredDate: java.util.Date, registeredDate: java.util.Date,
updatedDate: java.util.Date, updatedDate: java.util.Date,
issueId: Option[Int] issueId: Option[Int],
originalCommitId: String,
originalOldLine: Option[Int],
originalNewLine: Option[Int]
) extends Comment ) extends Comment
case class CommitComments( case class CommitComments(

View File

@@ -49,7 +49,10 @@ trait CommitsService {
newLine = newLine, newLine = newLine,
registeredDate = currentDate, registeredDate = currentDate,
updatedDate = 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])( def updateCommitCommentPosition(commentId: Int, commitId: String, oldLine: Option[Int], newLine: Option[Int])(

View File

@@ -181,9 +181,9 @@ trait PullRequestService { self: IssuesService with CommitsService =>
// Collect comment positions // Collect comment positions
val positions = getCommitComments(pullreq.userName, pullreq.repositoryName, pullreq.commitIdTo, true) val positions = getCommitComments(pullreq.userName, pullreq.repositoryName, pullreq.commitIdTo, true)
.collect { .collect {
case CommitComment(_, _, _, commentId, _, _, Some(file), None, Some(newLine), _, _, _) => case CommitComment(_, _, _, commentId, _, _, Some(file), None, Some(newLine), _, _, _, _, _, _) =>
(file, commentId, Right(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)) (file, commentId, Left(oldLine))
} }
.groupBy { case (file, _, _) => file } .groupBy { case (file, _, _) => file }
@@ -348,7 +348,7 @@ trait PullRequestService { self: IssuesService with CommitsService =>
.groupBy { .groupBy {
case x: IssueComment => (Some(x.commentId), None, None, None) 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 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) case x => throw new MatchError(x)
} }
.toSeq .toSeq
@@ -366,7 +366,7 @@ trait PullRequestService { self: IssuesService with CommitsService =>
diff = loadCommitCommentDiff( diff = loadCommitCommentDiff(
userName, userName,
repositoryName, repositoryName,
comments.head.asInstanceOf[CommitComment].commitId, comments.head.asInstanceOf[CommitComment].originalCommitId,
fileName, fileName,
oldLine, oldLine,
newLine newLine