Skip to content

The Unified and Autonomous Development Platform

More bug fixes

robin shine13cfe2adcddb
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.java
index a0c3165b54..0b15fe0e0f 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
@@ -55,17 +55,8 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManag
public void updateInlineInfo(PullRequestComment comment) {
Preconditions.checkNotNull(comment.getInlineInfo());
- System.err.println("updating inline info...");
-
String latestCommitHash = comment.getRequest().getLatestUpdate().getHeadCommitHash();
- if (!comment.getNewCommitHash().equals(latestCommitHash)) {
- try {
- System.err.println("sleeping...");
- Thread.sleep(10000);
- System.err.println("sleeped.");
- } catch (InterruptedException e) {
- }
-
+ if (!latestCommitHash.equals(comment.getNewCommitHash())) {
List<DiffEntry> changes = comment.getRepository().getDiffs(comment.getNewCommitHash(),
latestCommitHash, true);
String oldCommitHash = comment.getOldCommitHash();
@@ -117,7 +108,10 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManag
}
}
} else {
- comment.getCompareWith().revision = latestCommitHash;
+ BlobIdent compareWith = comment.getCompareWith();
+ compareWith.revision = latestCommitHash;
+ // call setCompareWith in order to clear some cached info in comment object
+ comment.setCompareWith(compareWith);
}
} else {
BlobIdent newBlobIdent = null;
@@ -173,7 +167,10 @@ public class DefaultPullRequestCommentManager implements PullRequestCommentManag
comment.setCompareWith(newBlobIdent);
}
} else {
- comment.getBlobIdent().revision = latestCommitHash;
+ BlobIdent blobIdent = comment.getBlobIdent();
+ blobIdent.revision = latestCommitHash;
+ // call setBlobInfo in order to clear some cached info in comment object
+ comment.setBlobIdent(blobIdent);
}
}
dao.persist(comment);
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.java
index a60d423481..bc3646f373 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
@@ -123,19 +123,15 @@ public class PullRequestComment extends AbstractEntity {
private Pair<String, String> getOldAndNew() {
String rev = getBlobIdent().revision;
if (oldAndNew == null) {
- if (getCompareWith() != null) {
- List<String> commitHashes = getRequest().getCommentables();
- String compareRev = getCompareWith().revision;
- int index = commitHashes.indexOf(rev);
- int compareIndex = commitHashes.indexOf(compareRev);
- Preconditions.checkState(index != -1 && compareIndex != -1);
- if (index <= compareIndex)
- oldAndNew = new Pair<>(rev, compareRev);
- else
- oldAndNew = new Pair<>(compareRev, rev);
- } else {
- oldAndNew = new Pair<>(rev, rev);
- }
+ List<String> commitHashes = getRequest().getCommentables();
+ String compareRev = getCompareWith().revision;
+ int index = commitHashes.indexOf(rev);
+ int compareIndex = commitHashes.indexOf(compareRev);
+ Preconditions.checkState(index != -1 && compareIndex != -1);
+ if (index <= compareIndex)
+ oldAndNew = new Pair<>(rev, compareRev);
+ else
+ oldAndNew = new Pair<>(compareRev, rev);
}
return oldAndNew;
}
@@ -146,6 +142,7 @@ public class PullRequestComment extends AbstractEntity {
public void setInlineInfo(InlineInfo inlineInfo) {
this.inlineInfo = inlineInfo;
+ oldAndNew = null;
}
public String getOldCommitHash() {
@@ -164,6 +161,7 @@ public class PullRequestComment extends AbstractEntity {
if (inlineInfo == null)
inlineInfo = new InlineInfo();
inlineInfo.setBlobIdent(blobIdent);
+ oldAndNew = null;
}
public BlobIdent getCompareWith() {
@@ -174,6 +172,7 @@ public class PullRequestComment extends AbstractEntity {
if (inlineInfo == null)
inlineInfo = new InlineInfo();
inlineInfo.setCompareWith(compareWith);
+ oldAndNew = null;
}
public int getLine() {
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.java
index 6d52604d5d..0a7e112c97 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
@@ -89,10 +89,11 @@ public class TextDiffPanel extends Panel {
@Override
protected List<CommentAndPos> load() {
List<CommentAndPos> listOfCommentAndPos = new ArrayList<>();
- if (requestModel.getObject() != null) {
- PullRequest request = requestModel.getObject();
+ PullRequest request = requestModel.getObject();
+ if (request != null) {
for (PullRequestComment comment: request.getComments()) {
if (comment.getInlineInfo() != null) {
+ System.err.println(comment);
GitPlex.getInstance(PullRequestCommentManager.class).updateInlineInfo(comment);
BlobIdent blobIdent = comment.getBlobIdent();
if (blobIdent.equals(change.getOldBlobIdent())) {
@@ -429,7 +430,7 @@ public class TextDiffPanel extends Panel {
}
private void appendAddComment(StringBuilder builder, int oldLineNo, int newLineNo) {
- if (commentModel.getObject() != null) {
+ if (requestModel.getObject() != null) {
builder.append("<span class='add-comment'>");
String script = String.format("document.getElementById('%s').addComment(%d, %d);",
getMarkupId(), oldLineNo, newLineNo);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java
index 43c026252f..a1a6348c5f 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/file/RepoFilePage.java
@@ -392,7 +392,7 @@ public class RepoFilePage extends RepositoryPage implements BlobViewContext {
}
};
- commentContext.setOutputMarkupId(true);
+ commentContext.setOutputMarkupPlaceholderTag(true);
if (target != null) {
replace(commentContext);
target.add(commentContext);
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.java
index 3a2def0b7d..c8163ea349 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
@@ -174,7 +174,7 @@ public class RequestComparePage extends RequestDetailPage {
private void initFromState(HistoryState state) {
PullRequest request = getPullRequest();
PullRequestComment comment = commentModel.getObject();
- if (comment != null && comment.getId() != null) {
+ if (comment != null) {
oldCommitHash = comment.getOldCommitHash();
newCommitHash = comment.getNewCommitHash();
path = comment.getBlobIdent().path;