The Unified and Autonomous Development Platform
Fix bugs
robin shine2b980cddcf7c
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/Comment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/Comment.javaindex 63a6084088..93e518b9d9 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/Comment.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/Comment.java@@ -26,6 +26,8 @@ public interface Comment extends Serializable {Collection<? extends CommentReply> getReplies();+ CommentReply loadReply(Long replyId);+CommentReply addReply(String content);/**diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineComment.javaindex 293afda59f..8ec237d7bc 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineComment.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineComment.java@@ -5,7 +5,7 @@ import com.pmease.commons.lang.diff.AroundContext;public interface InlineComment extends Comment {- public static final int CONTEXT_SIZE = 7;+ public static final int CONTEXT_SIZE = 3;BlobIdent getBlobIdent();diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineCommentSupport.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineCommentSupport.javaindex 9ec093b338..c1ae7067d2 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineCommentSupport.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/InlineCommentSupport.java@@ -16,4 +16,5 @@ public interface InlineCommentSupport extends Serializable {InlineComment getConcernedComment();+ InlineComment loadComment(Long commentId);}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.javaindex ecd29006cf..0c8accbce1 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestCommentManager.java@@ -52,28 +52,28 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManagList<Change> changes = comment.getRepository().getChanges(comment.getNewCommitHash(), latestCommitHash);String oldCommitHash = comment.getOldCommitHash();if (oldCommitHash.equals(comment.getBlobIdent().revision)) {- BlobIdent newBlobInfo = null;+ BlobIdent newBlobIdent = null;if (comment.getCompareWith().path != null) {for (Change change: changes) {if (comment.getCompareWith().path.equals(change.getOldBlobIdent().path)) {- newBlobInfo = new BlobIdent(latestCommitHash, change.getNewBlobIdent().path, change.getNewBlobIdent().mode);+ newBlobIdent = new BlobIdent(latestCommitHash, change.getNewBlobIdent().path, change.getNewBlobIdent().mode);break;}}} else {for (Change change: changes) {if (comment.getBlobIdent().path.equals(change.getNewBlobIdent().path)) {- newBlobInfo = new BlobIdent(latestCommitHash, change.getNewBlobIdent().path, change.getNewBlobIdent().mode);+ newBlobIdent = new BlobIdent(latestCommitHash, change.getNewBlobIdent().path, change.getNewBlobIdent().mode);break;}}}- if (newBlobInfo != null) {+ if (newBlobIdent != null) {Blob.Text oldText = comment.getRepository().getBlob(comment.getBlobIdent()).getText();Preconditions.checkNotNull(oldText);List<String> newLines;- if (newBlobInfo.path != null) {- Blob.Text newText = comment.getRepository().getBlob(newBlobInfo).getText();+ if (newBlobIdent.path != null) {+ Blob.Text newText = comment.getRepository().getBlob(newBlobIdent).getText();if (newText != null)newLines = newText.getLines();else@@ -83,31 +83,31 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManag}if (newLines != null) {List<DiffBlock> diffs = DiffUtils.diff(oldText.getLines(),- comment.getBlobIdent().getFileName(), newLines, newBlobInfo.getFileName());+ comment.getBlobIdent().getFileName(), newLines, newBlobIdent.getFileName());AroundContext context = DiffUtils.around(diffs, comment.getLine(), -1, InlineComment.CONTEXT_SIZE);comment.setContext(context);} else {comment.setContext(null);}- comment.setCompareWith(newBlobInfo);+ comment.setCompareWith(newBlobIdent);} else {comment.getCompareWith().revision = latestCommitHash;}} else {- BlobIdent newBlobInfo = null;+ BlobIdent newBlobIdent = null;for (Change change: changes) {if (comment.getBlobIdent().path.equals(change.getOldBlobIdent().path)) {- newBlobInfo = new BlobIdent(latestCommitHash, change.getNewBlobIdent().path, change.getNewBlobIdent().mode);+ newBlobIdent = new BlobIdent(latestCommitHash, change.getNewBlobIdent().path, change.getNewBlobIdent().mode);break;}}- if (newBlobInfo != null) {+ if (newBlobIdent != null) {Blob.Text oldText = comment.getRepository().getBlob(comment.getBlobIdent()).getText();Preconditions.checkNotNull(oldText);List<String> newLines;- if (newBlobInfo.path != null) {- Blob.Text newText = comment.getRepository().getBlob(newBlobInfo).getText();+ if (newBlobIdent.path != null) {+ Blob.Text newText = comment.getRepository().getBlob(newBlobIdent).getText();if (newText != null)newLines = newText.getLines();else@@ -117,10 +117,10 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManag}if (newLines != null) {List<DiffBlock> diffs = DiffUtils.diff(oldText.getLines(), comment.getBlobIdent().getFileName(),- newLines, newBlobInfo.getFileName());+ newLines, newBlobIdent.getFileName());Integer newLineNo = DiffUtils.mapLines(diffs).get(comment.getLine());if (newLineNo != null) {- comment.setBlobIdent(newBlobInfo);+ comment.setBlobIdent(newBlobIdent);comment.setLine(newLineNo);List<String> oldLines;@@ -136,7 +136,7 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManagif (oldLines != null) {diffs = DiffUtils.diff(oldLines,comment.getCompareWith().getFileName(),- newLines, newBlobInfo.getFileName());+ newLines, newBlobIdent.getFileName());AroundContext context = DiffUtils.around(diffs, -1, newLineNo, InlineComment.CONTEXT_SIZE);comment.setContext(context);@@ -144,14 +144,14 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManagcomment.setContext(null);}} else {- comment.setCompareWith(newBlobInfo);+ comment.setCompareWith(newBlobIdent);AroundContext context = DiffUtils.around(diffs, comment.getLine(), -1, InlineComment.CONTEXT_SIZE);comment.setContext(context);}} else {- comment.setCompareWith(newBlobInfo);+ comment.setCompareWith(newBlobIdent);comment.setContext(null);}} else {diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.javaindex 8483cd224d..dbc2205c24 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestComment.java@@ -207,4 +207,9 @@ public class PullRequestComment extends AbstractEntity implements InlineCommentreturn GitPlex.getInstance(PullRequestManager.class).getLastVisitDate(getRequest());}+ @Override+ public CommentReply loadReply(Long replyId) {+ return GitPlex.getInstance(Dao.class).load(PullRequestCommentReply.class, replyId);+ }+}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.javaindex 9e7d558306..32a4468e54 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CommentPanel.java@@ -320,7 +320,15 @@ public class CommentPanel extends Panel {}private Component newReplyRow(String id, CommentReply reply) {- final WebMarkupContainer row = new WebMarkupContainer(id, Model.of(reply));+ final Long replyId = reply.getId();+ final WebMarkupContainer row = new WebMarkupContainer(id, new LoadableDetachableModel<CommentReply>() {++ @Override+ protected CommentReply load() {+ return getComment().loadReply(replyId);+ }++ });row.setOutputMarkupId(true);WebMarkupContainer avatarColumn = new WebMarkupContainer("avatar");diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.javaindex 9173f0f3ea..299ef0deb9 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java@@ -50,6 +50,7 @@ import com.pmease.commons.lang.tokenizers.CmToken;import com.pmease.commons.util.StringUtils;import com.pmease.commons.wicket.behavior.DirtyIgnoreBehavior;import com.pmease.commons.wicket.component.feedback.FeedbackPanel;+import com.pmease.gitplex.core.comment.Comment;import com.pmease.gitplex.core.comment.InlineComment;import com.pmease.gitplex.core.comment.InlineCommentSupport;import com.pmease.gitplex.core.model.Repository;@@ -146,7 +147,14 @@ public class TextDiffPanel extends Panel {PageParameters params = RepoFilePage.paramsOf(repoModel.getObject(), change.getBlobIdent());add(new BookmarkablePageLink<Void>("viewFile", RepoFilePage.class, params));- add(new Label("diffLines", renderDiffs()).setEscapeModelStrings(false));+ add(new Label("diffLines", new LoadableDetachableModel<String>() {++ @Override+ protected String load() {+ return renderDiffs();+ }++ }).setEscapeModelStrings(false));add(new AbstractDefaultAjaxBehavior() {@@ -607,7 +615,15 @@ public class TextDiffPanel extends Panel {};row.add(new UserLink("avatar", new UserModel(commentAndPos.comment.getUser()), AvatarMode.AVATAR));- row.add(new CommentPanel("detail", Model.of(commentAndPos.comment)));+ final Long commentId = commentAndPos.comment.getId();+ row.add(new CommentPanel("detail", new LoadableDetachableModel<Comment>() {++ @Override+ protected Comment load() {+ return commentSupport.loadComment(commentId);+ }++ }));if (commentAndPos.comment.equals(commentSupport.getConcernedComment()))row.add(AttributeAppender.append("class", " concerned"));diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.javaindex 84cef74240..14e3e63a53 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/pullrequest/requestdetail/compare/RequestComparePage.java@@ -651,6 +651,11 @@ public class RequestComparePage extends RequestDetailPage {}return comment;}++ @Override+ public InlineComment loadComment(Long commentId) {+ return GitPlex.getInstance(Dao.class).load(PullRequestComment.class, commentId);+ }};};