Skip to content

The Unified and Autonomous Development Platform

Change back to use merged comments.

robin shine546f01a8e82c
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/BlobLoader.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/BlobLoader.java
new file mode 100644
index 0000000000..19a5632606
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/BlobLoader.java
@@ -0,0 +1,22 @@
+package com.pmease.gitplex.core.comment;
+
+import java.util.List;
+
+import javax.annotation.Nullable;
+
+import com.pmease.commons.git.BlobInfo;
+
+public interface BlobLoader {
+
+ /**
+ * Load content of specified blob and convert to lines.
+ *
+ * @param blobInfo
+ * blob info to load
+ * @return
+ * lines of the blob, or null if the blob content can not be
+ * converted to text
+ */
+ @Nullable
+ List<String> loadBlob(BlobInfo blobInfo);
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/ChangeLoader.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/ChangeLoader.java
new file mode 100644
index 0000000000..060599b628
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/ChangeLoader.java
@@ -0,0 +1,9 @@
+package com.pmease.gitplex.core.comment;
+
+import java.util.List;
+
+import com.pmease.commons.git.Change;
+
+public interface ChangeLoader {
+ List<Change> loadChanges(String fromRev, String toRev);
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/CommentAwareChange.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/CommentAwareChange.java
index 14b60df911..3382626345 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/CommentAwareChange.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/CommentAwareChange.java
@@ -2,103 +2,206 @@ package com.pmease.gitplex.core.comment;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import javax.annotation.Nullable;
-import com.google.common.base.Preconditions;
+import com.pmease.commons.git.BlobInfo;
import com.pmease.commons.git.RevAwareChange;
import com.pmease.commons.hibernate.dao.Dao;
+import com.pmease.commons.util.Pair;
+import com.pmease.commons.util.diff.DiffUtils;
import com.pmease.gitplex.core.GitPlex;
-import com.pmease.gitplex.core.manager.CommitCommentManager;
import com.pmease.gitplex.core.model.CommentPosition;
import com.pmease.gitplex.core.model.CommitComment;
-import com.pmease.gitplex.core.model.Repository;
@SuppressWarnings("serial")
public class CommentAwareChange extends RevAwareChange {
- private final Map<Integer, List<CommitComment>> oldComments;
+ private Map<Integer, List<CommitComment>> oldComments;
- private final Map<Integer, List<CommitComment>> newComments;
+ private Map<Integer, List<CommitComment>> newComments;
private final CommitComment concernedComment;
- public CommentAwareChange(Repository repo, RevAwareChange change, boolean enableOldComments,
- boolean enableNewComments, @Nullable CommitComment concernedComment) {
+ public CommentAwareChange(RevAwareChange change, List<String> commits,
+ CommentLoader commentLoader, BlobLoader blobLoader,
+ CommitComment concernedComment) {
super(change);
-
+
this.concernedComment = concernedComment;
- if (enableOldComments && getOldPath() != null) {
- oldComments = new HashMap<>();
- CommitCommentManager manager = GitPlex.getInstance(CommitCommentManager.class);
- for (CommitComment comment: manager.findByCommitAndFile(repo, getOldRevision(), getOldPath())) {
- CommentPosition position = comment.getPosition();
- if (position != null && position.getLineNo() != null
- && position.getFilePath().equals(getOldPath())) {
- List<CommitComment> lineComments = oldComments.get(position.getLineNo());
- if (lineComments == null) {
- lineComments = new ArrayList<>();
- oldComments.put(position.getLineNo(), lineComments);
+ Map<String, Map<String, List<CommitComment>>> comments = new HashMap<>();
+ Map<BlobInfo, List<String>> blobs = new HashMap<>();
+
+ int end = -1;
+ if (change.getNewPath() != null) {
+ end = commits.indexOf(change.getNewRevision());
+ if (end != -1 && getBlob(blobs, change.getNewBlobInfo(), blobLoader).isEmpty())
+ end = -1;
+ }
+
+ int begin = -1;
+ if (change.getOldPath() != null) {
+ begin = commits.indexOf(change.getOldRevision());
+ if (begin != -1 && getBlob(blobs, change.getOldBlobInfo(), blobLoader).isEmpty())
+ begin = -1;
+ }
+
+ if (end != -1) {
+ newComments = new HashMap<>();
+
+ for (int i=end-1; i>begin; i--) {
+ String commit = commits.get(i);
+ Map<String, List<CommitComment>> commentsOnCommit = getCommentsOnCommit(comments, commit, commentLoader);
+ BlobInfo blobInfo = null;
+ List<CommitComment> commentsOnFile = commentsOnCommit.get(change.getNewPath());
+ if (commentsOnFile != null) {
+ blobInfo = new BlobInfo(commit, change.getNewPath(), change.getNewMode());
+ } else {
+ commentsOnFile = commentsOnCommit.get(change.getOldPath());
+ if (commentsOnFile != null)
+ blobInfo = new BlobInfo(commit, change.getOldPath(), change.getOldMode());
+ }
+
+ if (blobInfo != null) {
+ List<String> fileContent = getBlob(blobs, blobInfo, blobLoader);
+ if (!fileContent.isEmpty()) {
+ List<String> newContent = getBlob(blobs, change.getNewBlobInfo(), blobLoader);
+ Map<Integer, Integer> lineMap = DiffUtils.mapLines(fileContent, newContent);
+ for (CommitComment comment: commentsOnFile) {
+ Integer lineNo = lineMap.get(comment.getPosition().getLineNo());
+ if (lineNo != null)
+ addLineComment(newComments, lineNo, comment);
+ }
}
- lineComments.add(comment);
}
}
- } else {
- oldComments = null;
+
+ List<CommitComment> commentsOnFile = getCommentsOnCommit(comments, change.getNewRevision(), commentLoader).get(change.getNewPath());
+ if (commentsOnFile != null) {
+ for (CommitComment comment: commentsOnFile)
+ addLineComment(newComments, comment.getPosition().getLineNo(), comment);
+ }
}
- if (enableNewComments && getNewPath() != null) {
- newComments = new HashMap<>();
- CommitCommentManager manager = GitPlex.getInstance(CommitCommentManager.class);
- for (CommitComment comment: manager.findByCommitAndFile(repo, getNewRevision(), getNewPath())) {
- CommentPosition position = comment.getPosition();
- if (position != null && position.getLineNo() != null
- && position.getFilePath().equals(getOldPath())) {
- List<CommitComment> lineComments = newComments.get(position.getLineNo());
- if (lineComments == null) {
- lineComments = new ArrayList<>();
- newComments.put(position.getLineNo(), lineComments);
+ if (begin != -1) {
+ oldComments = new HashMap<>();
+
+ Set<CommentKey> appliedComments = new HashSet<>();
+ if (newComments != null) {
+ for (List<CommitComment> list: newComments.values()) {
+ for (CommitComment comment: list)
+ appliedComments.add(new CommentKey(comment.getCommit(), comment.getPosition()));
+ }
+ }
+
+ for (int i=begin+1; i<(end!=-1?end:commits.size()); i++) {
+ String commit = commits.get(i);
+ Map<String, List<CommitComment>> commentsOnCommit = getCommentsOnCommit(comments, commit, commentLoader);
+ BlobInfo blobInfo = null;
+ List<CommitComment> commentsOnFile = commentsOnCommit.get(change.getOldPath());
+ if (commentsOnFile != null) {
+ blobInfo = new BlobInfo(commit, change.getOldPath(), change.getOldMode());
+ } else {
+ commentsOnFile = commentsOnCommit.get(change.getNewPath());
+ if (commentsOnFile != null)
+ blobInfo = new BlobInfo(commit, change.getNewPath(), change.getNewMode());
+ }
+
+ if (blobInfo != null) {
+ boolean allApplied = true;
+ for (CommitComment comment: commentsOnFile) {
+ CommentKey key = new CommentKey(comment.getCommit(), comment.getPosition());
+ if (!appliedComments.contains(key)) {
+ allApplied = false;
+ break;
+ }
+ }
+ if (!allApplied) {
+ List<String> fileContent = blobLoader.loadBlob(blobInfo);
+ if (!fileContent.isEmpty()) {
+ List<String> oldContent = getBlob(blobs, change.getOldBlobInfo(), blobLoader);
+ Map<Integer, Integer> lineMap = DiffUtils.mapLines(fileContent, oldContent);
+ for (CommitComment comment: commentsOnFile) {
+ CommentKey key = new CommentKey(comment.getCommit(), comment.getPosition());
+ Integer lineNo = lineMap.get(comment.getPosition().getLineNo());
+ if (!appliedComments.contains(key) && lineNo != null)
+ addLineComment(oldComments, lineNo, comment);
+ }
+ }
}
- lineComments.add(comment);
}
}
- } else {
- newComments = null;
+
+ List<CommitComment> commentsOnFile = getCommentsOnCommit(comments, change.getOldRevision(), commentLoader).get(change.getOldPath());
+ if (commentsOnFile != null) {
+ for (CommitComment comment: commentsOnFile)
+ addLineComment(oldComments, comment.getPosition().getLineNo(), comment);
+ }
}
+
}
-
- public CommitComment getConcernedComment() {
- return concernedComment;
+
+ private void addLineComment(Map<Integer, List<CommitComment>> comments, int lineNo, CommitComment comment) {
+ List<CommitComment> commentsOnLine = comments.get(lineNo);
+ if (commentsOnLine == null) {
+ commentsOnLine = new ArrayList<>();
+ comments.put(lineNo, commentsOnLine);
+ }
+ commentsOnLine.add(comment);
+ }
+
+ private Map<String, List<CommitComment>> getCommentsOnCommit(Map<String, Map<String, List<CommitComment>>> comments,
+ String commit, CommentLoader commentLoader) {
+ Map<String, List<CommitComment>> commentsOnCommit = comments.get(commit);
+ if (commentsOnCommit == null) {
+ commentsOnCommit = new HashMap<>();
+ for (CommitComment each: commentLoader.loadComments(commit)) {
+ if (each.getPosition() != null && each.getPosition().getLineNo() != null) {
+ List<CommitComment> commentsOnFile = commentsOnCommit.get(each.getPosition().getFilePath());
+ if (commentsOnFile == null) {
+ commentsOnFile = new ArrayList<>();
+ commentsOnCommit.put(each.getPosition().getFilePath(), commentsOnFile);
+ }
+ commentsOnFile.add(each);
+ }
+ }
+ comments.put(commit, commentsOnCommit);
+ }
+ return commentsOnCommit;
}
+ @Nullable
public Map<Integer, List<CommitComment>> getOldComments() {
return oldComments;
}
+ @Nullable
public Map<Integer, List<CommitComment>> getNewComments() {
return newComments;
}
-
- public void saveComment(CommitComment comment) {
- boolean isNew = comment.isNew();
- GitPlex.getInstance(Dao.class).persist(comment);
-
- if (isNew) {
- if (comment.getCommit().equals(getOldRevision())) {
- addComment(Preconditions.checkNotNull(oldComments), comment);
- } else if (comment.getCommit().equals(getNewRevision())) {
- addComment(Preconditions.checkNotNull(newComments), comment);
- } else {
- throw new IllegalStateException();
- }
+
+ private List<String> getBlob(Map<BlobInfo, List<String>> blobs, BlobInfo blobInfo, BlobLoader blobLoader) {
+ List<String> blob = blobs.get(blobInfo);
+ if (blob == null) {
+ blob = blobLoader.loadBlob(blobInfo);
+ if (blob == null)
+ blob = new ArrayList<>();
+ blobs.put(blobInfo, blob);
}
+ return blob;
}
+ public CommitComment getConcernedComment() {
+ return concernedComment;
+ }
+
public boolean contains(CommitComment comment) {
if (oldComments != null) {
for (List<CommitComment> lineComments: oldComments.values()) {
@@ -119,17 +222,36 @@ public class CommentAwareChange extends RevAwareChange {
return false;
}
- public void removeComment(CommitComment comment) {
- GitPlex.getInstance(Dao.class).remove(comment);
+ public void saveComment(CommitComment comment) {
+ boolean isNew = comment.isNew();
+ GitPlex.getInstance(Dao.class).persist(comment);
- if (comment.getCommit().equals(getOldRevision())) {
- removeComment(Preconditions.checkNotNull(oldComments), comment);
- } else if (comment.getCommit().equals(getNewRevision())) {
- removeComment(Preconditions.checkNotNull(newComments), comment);
- } else {
- throw new IllegalStateException();
+ if (isNew) {
+ if (oldComments != null && (comment.getCommit().equals(getOldRevision()) || contains(oldComments, comment.getCommit())))
+ addComment(oldComments, comment);
+ if (newComments != null && (comment.getCommit().equals(getNewRevision()) || contains(newComments, comment.getCommit())))
+ addComment(newComments, comment);
}
}
+
+ private boolean contains(Map<Integer, List<CommitComment>> comments, String commit) {
+ for (List<CommitComment> lineComments: comments.values()) {
+ for (CommitComment lineComment: lineComments) {
+ if (lineComment.getCommit().equals(commit))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void removeComment(CommitComment comment) {
+ GitPlex.getInstance(Dao.class).remove(comment);
+
+ if (oldComments != null)
+ removeComment(oldComments, comment);
+ if (newComments != null )
+ removeComment(newComments, comment);
+ }
private void removeComment(Map<Integer, List<CommitComment>> comments, CommitComment comment) {
for (Iterator<Entry<Integer, List<CommitComment>>> it = comments.entrySet().iterator(); it.hasNext();) {
@@ -149,5 +271,13 @@ public class CommentAwareChange extends RevAwareChange {
}
lineComments.add(comment);
}
-
+
+ private static class CommentKey extends Pair<String, CommentPosition> {
+
+ public CommentKey(String commit, CommentPosition position) {
+ super(commit, position);
+ }
+
+ }
+
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/CommentLoader.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/CommentLoader.java
new file mode 100644
index 0000000000..b82edabbfb
--- /dev/null
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/comment/CommentLoader.java
@@ -0,0 +1,20 @@
+package com.pmease.gitplex.core.comment;
+
+import java.util.List;
+
+import com.pmease.gitplex.core.model.CommitComment;
+
+public interface CommentLoader {
+ /**
+ * Load list of comments on specified commit, ordered by comment id.
+ *
+ * @param commit
+ * commit to load comments for
+ * @return
+ * list of commit comments on specified commit ordered by comment id,
+ * including comments on commit itself, comments on files in the commit,
+ * and comments on file lines in the commit. Empty list should be
+ * returned if there are no any comments on specified commit
+ */
+ List<CommitComment> loadComments(String commit);
+}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java
index ca08b32fc8..e22b2773b3 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/manager/impl/DefaultPullRequestManager.java
@@ -117,7 +117,7 @@ public class DefaultPullRequestManager implements PullRequestManager {
closeInfo.setComment("Target branch already contains commit of source branch.");
request.setCloseInfo(closeInfo);
request.setCheckResult(new Approved("Already integrated."));
- request.setIntegrationInfo(new IntegrationInfo(branchHead, requestHead, branchHead, null));
+ request.setIntegrationInfo(new IntegrationInfo(branchHead, requestHead, branchHead, null, true));
} else {
// Update head ref so that it can be pulled by build system
git.updateRef(request.getHeadRef(), requestHead, null, null);
@@ -132,7 +132,7 @@ public class DefaultPullRequestManager implements PullRequestManager {
&& !request.getIntegrationInfo().getIntegrationHead().equals(git.parseRevision(integrateRef, false))) {
if (strategy == MERGE_IF_NECESSARY && git.isAncestor(branchHead, requestHead)) {
- request.setIntegrationInfo(new IntegrationInfo(branchHead, requestHead, requestHead, strategy));
+ request.setIntegrationInfo(new IntegrationInfo(branchHead, requestHead, requestHead, strategy, false));
git.updateRef(integrateRef, requestHead, null, null);
} else {
File tempDir = FileUtils.createTempDir();
@@ -142,6 +142,7 @@ public class DefaultPullRequestManager implements PullRequestManager {
request.getTarget().getName());
String integrateHead;
+
if (strategy == REBASE_TARGET) {
tempGit.updateRef("HEAD", requestHead, null, null);
tempGit.reset(null, null);
@@ -161,13 +162,17 @@ public class DefaultPullRequestManager implements PullRequestManager {
"Merge pull request: " + request.getTitle());
}
}
-
- request.setIntegrationInfo(new IntegrationInfo(branchHead, requestHead, integrateHead, strategy));
-
- if (integrateHead != null)
- git.fetch(tempGit, "+HEAD:" + integrateRef);
- else
+
+ if (integrateHead != null) {
+ request.setIntegrationInfo(new IntegrationInfo(
+ branchHead, requestHead, integrateHead, strategy,
+ !tempGit.listChangedFiles(requestHead, integrateHead, null).isEmpty()));
+ git.fetch(tempGit, "+HEAD:" + integrateRef);
+ } else {
+ request.setIntegrationInfo(new IntegrationInfo(branchHead, requestHead,
+ integrateHead, strategy, false));
git.deleteRef(integrateRef, null, null);
+ }
} finally {
FileUtils.deleteDir(tempDir);
}
diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/IntegrationInfo.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/IntegrationInfo.java
index 6dd3d4618c..8a933b902d 100644
--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/IntegrationInfo.java
+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/IntegrationInfo.java
@@ -15,6 +15,10 @@ public class IntegrationInfo implements Serializable {
private String integrationHead;
+ // Use Boolean instead of boolean to avoid Hibernate limitation
+ // on embedded property
+ private Boolean hasChanges;
+
private IntegrationStrategy integrationStrategy;
@SuppressWarnings("unused")
@@ -22,11 +26,12 @@ public class IntegrationInfo implements Serializable {
}
public IntegrationInfo(String branchHead, String requestHead, @Nullable String integrationHead,
- IntegrationStrategy integrationStrategy) {
+ @Nullable IntegrationStrategy integrationStrategy, boolean hasChanges) {
this.branchHead = branchHead;
this.requestHead = requestHead;
this.integrationHead = integrationHead;
this.integrationStrategy = integrationStrategy;
+ this.hasChanges = hasChanges;
}
public String getBranchHead() {
@@ -58,5 +63,9 @@ public class IntegrationInfo implements Serializable {
public @Nullable IntegrationStrategy getIntegrationStrategy() {
return integrationStrategy;
}
-
+
+ public boolean hasChanges() {
+ return hasChanges != null && hasChanges;
+ }
+
}
\ No newline at end of file
diff --git a/gitplex.core/src/test/java/com/pmease/gitplex/core/comment/CommentAwareChangeTest.java b/gitplex.core/src/test/java/com/pmease/gitplex/core/comment/CommentAwareChangeTest.java
new file mode 100644
index 0000000000..046d3509fb
--- /dev/null
+++ b/gitplex.core/src/test/java/com/pmease/gitplex/core/comment/CommentAwareChangeTest.java
@@ -0,0 +1,199 @@
+package com.pmease.gitplex.core.comment;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.Test;
+
+import com.pmease.commons.git.AbstractGitTest;
+import com.pmease.commons.git.BlobInfo;
+import com.pmease.commons.git.Change;
+import com.pmease.commons.git.Commit;
+import com.pmease.commons.git.RevAwareChange;
+import com.pmease.gitplex.core.model.CommentPosition;
+import com.pmease.gitplex.core.model.CommitComment;
+
+public class CommentAwareChangeTest extends AbstractGitTest {
+
+ @Test
+ public void test() {
+ final List<String> fileRevs = new ArrayList<>();
+ fileRevs.add(""
+ + "11\n" //comment1
+ + "22\n"
+ + "33\n"
+ + "44\n"
+ + "55\n" //comment3, comment6
+ + "66\n"
+ + "77\n"
+ + "88\n" //comment4
+ + "99\n");
+ fileRevs.add(""
+ + "111\n"
+ + "222\n"
+ + "33\n"
+ + "44\n"
+ + "55\n"
+ + "66\n"
+ + "77\n"
+ + "88\n"
+ + "99\n");
+ fileRevs.add(""
+ + "111\n"
+ + "222\n"
+ + "33\n"
+ + "44\n"
+ + "55\n"
+ + "66\n"
+ + "77\n"
+ + "888\n"
+ + "999\n");
+ fileRevs.add(""
+ + "111\n"
+ + "222\n" //comment2
+ + "33\n"
+ + "44\n" //comment5
+ + "555\n"
+ + "66\n"
+ + "77\n"
+ + "8888\n"
+ + "999\n"); //comment8, comment9
+
+ addFileAndCommit("file1", fileRevs.get(0), "add file1");
+
+ addFileAndCommit("file1", fileRevs.get(1), "modify file1");
+
+ addFileAndCommit("file1", fileRevs.get(2), "modify file1");
+
+ addFileAndCommit("file1", fileRevs.get(3), "modify file1");
+
+ final List<Commit> commits = new ArrayList<>();
+ commits.add(git.showRevision("master~3"));
+ commits.add(git.showRevision("master~2"));
+ commits.add(git.showRevision("master~1"));
+ commits.add(git.showRevision("master"));
+
+ CommentLoader commentLoader = new CommentLoader() {
+
+ @Override
+ public List<CommitComment> loadComments(String commit) {
+ List<CommitComment> comments = new ArrayList<>();
+
+ List<String> commitHashes = new ArrayList<>();
+ for (Commit each: commits)
+ commitHashes.add(each.getHash());
+
+ int index = commitHashes.indexOf(commit);
+ if (index == 0) {
+ CommitComment comment = new CommitComment();
+ comment.setId(1L);
+ comment.setCommit(commit);
+ comment.setContent("comment1");
+ comment.setPosition(new CommentPosition("file1", 0));
+ comments.add(comment);
+ } else if (index == 1) {
+ CommitComment comment = new CommitComment();
+ comment.setId(2L);
+ comment.setCommit(commit);
+ comment.setContent("comment2");
+ comment.setPosition(new CommentPosition("file1", 1));
+ comments.add(comment);
+
+ comment = new CommitComment();
+ comment.setId(3L);
+ comment.setCommit(commit);
+ comment.setContent("comment3");
+ comment.setPosition(new CommentPosition("file1", 4));
+ comments.add(comment);
+
+ comment = new CommitComment();
+ comment.setId(4L);
+ comment.setCommit(commit);
+ comment.setContent("comment4");
+ comment.setPosition(new CommentPosition("file1", 7));
+ comments.add(comment);
+ } else if (index == 2) {
+ CommitComment comment = new CommitComment();
+ comment.setId(5L);
+ comment.setCommit(commit);
+ comment.setContent("comment5");
+ comment.setPosition(new CommentPosition("file1", 3));
+ comments.add(comment);
+
+ comment = new CommitComment();
+ comment.setId(6L);
+ comment.setCommit(commit);
+ comment.setContent("comment6");
+ comment.setPosition(new CommentPosition("file1", 4));
+ comments.add(comment);
+
+ comment = new CommitComment();
+ comment.setId(7L);
+ comment.setCommit(commit);
+ comment.setContent("comment7");
+ comment.setPosition(new CommentPosition("file1", 7));
+ comments.add(comment);
+
+ comment = new CommitComment();
+ comment.setId(8L);
+ comment.setCommit(commit);
+ comment.setContent("comment8");
+ comment.setPosition(new CommentPosition("file1", 8));
+ comments.add(comment);
+ } else if (index == 3) {
+ CommitComment comment = new CommitComment();
+ comment.setId(9L);
+ comment.setCommit(commit);
+ comment.setContent("comment9");
+ comment.setPosition(new CommentPosition("file1", 8));
+ comments.add(comment);
+ }
+ return comments;
+ }
+
+ };
+
+ BlobLoader fileLoader = new BlobLoader() {
+
+ @Override
+ public List<String> loadBlob(BlobInfo blobInfo) {
+ List<String> commitHashes = new ArrayList<>();
+ for (Commit each: commits)
+ commitHashes.add(each.getHash());
+
+ int index = commitHashes.indexOf(blobInfo.getRevision());
+ String content = fileRevs.get(index);
+ try {
+ return IOUtils.readLines(new ByteArrayInputStream(content.getBytes()));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ };
+
+ RevAwareChange change = new RevAwareChange(Change.Status.MODIFIED, "file1", "file1",
+ 0, 0, commits.get(0).getHash(), commits.get(3).getHash());
+
+ List<String> commitHashes = new ArrayList<>();
+ for (Commit each: commits)
+ commitHashes.add(each.getHash());
+ CommentAwareChange commentAwareChange = new CommentAwareChange(change, commitHashes,
+ commentLoader, fileLoader, null);
+
+ assertEquals("comment1", commentAwareChange.getOldComments().get(0).get(0).getContent());
+ assertEquals("comment2", commentAwareChange.getNewComments().get(1).get(0).getContent());
+ assertEquals("comment3", commentAwareChange.getOldComments().get(4).get(0).getContent());
+ assertEquals("comment4", commentAwareChange.getOldComments().get(7).get(0).getContent());
+ assertEquals("comment5", commentAwareChange.getNewComments().get(3).get(0).getContent());
+ assertEquals("comment6", commentAwareChange.getOldComments().get(4).get(1).getContent());
+ assertEquals("comment8", commentAwareChange.getNewComments().get(8).get(0).getContent());
+ assertEquals("comment9", commentAwareChange.getNewComments().get(8).get(1).getContent());
+ }
+
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/assets/css/page.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/assets/css/page.css
index a0d064126b..55183f1a2b 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/assets/css/page.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/assets/css/page.css
@@ -806,15 +806,16 @@ table.line-comments>tbody>tr>.avatar img.avatar {width: 36px; height: 36px;}
table.line-comments>tbody>tr>.content {padding-left: 8px;}
table.line-comments>tbody>tr>.content>.head, table.line-comments>tbody>tr>.content>.head a {color: #888;}
table.line-comments>tbody>tr>.content>.head .pull-right {margin-left: 8px; font-size: 11px;}
-table.line-comments>tbody>tr>.content>.head .pull-right i {font-size: 12px;}
+table.line-comments>tbody>tr>.content>.head .pull-right i {font-size: 13px;}
table.line-comments>tbody>tr>.content>.head .name {font-weight: bold;}
table.line-comments>tbody>tr>.content>.body {margin: 12px 0 12px 0;}
-.table-diff .concerned-comments {color: #E9CB43; font-size: 24px; margin-bottom: 12px;}
+.table-diff .concerned-comments {color: #E9CB43; font-size: 20px; margin-bottom: 12px;}
-.table-diff .add-comment {position: absolute; left:0; margin-left: -20px; width: 20px; height: 20px;
- text-decoration: none;}
-.table-diff .add-comment .fa {display:none;}
-.table-diff tr:hover .add-comment .fa {display:inline;}
+.table-diff a.add-comment {position: absolute; left:0; margin-left: -20px;
+ width: 20px; height: 20px; text-decoration: none;}
+.table-diff a.add-comment .fa {display:none;}
+.table-diff tr:hover a.add-comment .fa {display:inline;}
+.table-diff div.add-comment {border-top: 1px dotted #bbb; padding-top: 12px;}
ul.diff-alerts li {text-align: left;}
ul.diff-alerts {padding-left: 12px;}
@@ -958,9 +959,8 @@ table.old-vs-new td.vs {width: 1px; text-align: center; font-weight: bold;}
background: url("/assets/img/commits.png") no-repeat 0 7px;
padding-left: 24px; width: 1px; position: relative;}
.update-commits tbody>tr>td.data.status {width: 1%; text-align: right; vertical-align: top;}
-.update-commits tbody>tr>td.info>.summary {font-family: monospace;}
-.update-commits tbody>tr>td.info>.message {font-size: 12px;}
-.update-commits tbody>tr>td.info>.threads {margin-top: 8px;}
+.update-commits tbody>tr>td.info>.summary, .update-commits tbody>tr>td.info>.message {font-family: monospace;}
+.update-commits tbody>tr>td.info>.threads {margin-top: 12px;}
.update-commits tbody>tr>td {border-top: 1px dotted #CCC; padding: 2px;}
.update-commits tbody>tr:FIRST-CHILD>td, .update-commits tbody>tr>td.handle {
border-top: none;}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.html
index ee7870542c..12c9656c8c 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.html
@@ -37,7 +37,7 @@
</tr>
<tr wicket:id="commentsRow" class="line comments">
<td colspan="2" class="summary">
- <div><i wicket:id="concernedTip" class="fa fa-light-bulb concerned-comments"></i></div>
+ <div><i wicket:id="concernedFlag" class="fa fa-flag concerned-comments" title="Concerned comments"></i></div>
<div><i class="fa fa-comment"></i> <span wicket:id="commentCount"></span></div>
</td>
<td class="detail">
@@ -51,13 +51,18 @@
<span wicket:id="name" class="pull-left"></span>
<a wicket:id="edit" class="pull-right" title="Edit this comment"><i class="fa fa-pencil"></i></a>
<a wicket:id="delete" class="pull-right" title="Delete this comment"><i class="fa fa-times"></i></a>
+ <a wicket:id="reply" class="pull-right" title="Reply this comment"><i class="fa fa-mail-reply"></i></a>
<span wicket:id="age" class="pull-right"></span>
</div>
<div wicket:id="content" class="body"></div>
</td>
</tr>
</table>
- <a wicket:id="addComment" class="btn btn-sm btn-default">Add a comment</a>
+ <wicket:enclosure child="addComment">
+ <div class="add-comment">
+ <a wicket:id="addComment">Add a comment</a>
+ </div>
+ </wicket:enclosure>
<div wicket:id="newComment"></div>
</td>
</tr>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.java
index c8fccd5e98..705dba5344 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/TextDiffPanel.java
@@ -10,6 +10,8 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
+import jersey.repackaged.com.google.common.base.Splitter;
+
import org.apache.shiro.SecurityUtils;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
@@ -40,7 +42,6 @@ import com.pmease.commons.util.diff.WordSplitter;
import com.pmease.commons.wicket.behavior.ConfirmBehavior;
import com.pmease.commons.wicket.behavior.ScrollBehavior;
import com.pmease.commons.wicket.behavior.StickyBehavior;
-import com.pmease.commons.wicket.behavior.TooltipBehavior;
import com.pmease.commons.wicket.behavior.menu.CheckMenuItem;
import com.pmease.commons.wicket.behavior.menu.MenuBehavior;
import com.pmease.commons.wicket.behavior.menu.MenuItem;
@@ -63,9 +64,6 @@ import com.pmease.gitplex.web.component.user.UserLink;
import com.pmease.gitplex.web.event.CommitCommentRemoved;
import com.pmease.gitplex.web.model.UserModel;
-import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig;
-import de.agilecoders.wicket.core.markup.html.bootstrap.components.TooltipConfig.Placement;
-
@SuppressWarnings("serial")
public class TextDiffPanel extends Panel {
@@ -102,6 +100,8 @@ public class TextDiffPanel extends Panel {
private boolean showComments = true;
private List<DiffLine> diffs;
+
+ private String autoScrollScript;
public TextDiffPanel(String id, final IModel<Repository> repoModel,
BlobText oldText, BlobText newText, CommentAwareChange change) {
@@ -423,7 +423,7 @@ public class TextDiffPanel extends Panel {
}) {
@Override
- protected void populateItem(ListItem<DiffLine> lineItem) {
+ protected void populateItem(final ListItem<DiffLine> lineItem) {
final DiffLine diffLine = lineItem.getModelObject();
final WebMarkupContainer contentRow = new WebMarkupContainer(CONTENT_ROW_ID);
@@ -463,7 +463,7 @@ public class TextDiffPanel extends Panel {
}
}));
- WebMarkupContainer concernedTip = new WebMarkupContainer("concernedTip") {
+ commentsRow.add(new WebMarkupContainer("concernedFlag") {
@Override
protected void onConfigure() {
@@ -472,10 +472,7 @@ public class TextDiffPanel extends Panel {
setVisible(lineCommentsModel.getObject().contains(change.getConcernedComment()));
}
- };
- String message = "You may also view concerned comments by comparing concerned commit with other commits above";
- concernedTip.add(new TooltipBehavior(Model.of(message), new TooltipConfig().withPlacement(Placement.right)));
- commentsRow.add(concernedTip);
+ });
commentsRow.add(new ListView<CommitComment>("comments", lineCommentsModel) {
@@ -494,6 +491,8 @@ public class TextDiffPanel extends Panel {
}));
+ commentItem.add(new AddCommentLink("reply", lineItem, comment));
+
commentItem.add(new AjaxLink<Void>("edit") {
@Override
@@ -508,7 +507,6 @@ public class TextDiffPanel extends Panel {
@Override
public void onClick(AjaxRequestTarget target) {
- commentsRow.replace(new WebMarkupContainer(NEW_COMMENT_ID));
target.add(commentsRow);
}
@@ -588,7 +586,7 @@ public class TextDiffPanel extends Panel {
});
- commentsRow.add(new AddCommentLink("addComment", lineItem) {
+ commentsRow.add(new AddCommentLink("addComment", lineItem, null) {
@Override
protected void onConfigure() {
@@ -604,7 +602,7 @@ public class TextDiffPanel extends Panel {
lineItem.add(commentsRow);
- contentRow.add(new AddCommentLink("addComment", lineItem));
+ contentRow.add(new AddCommentLink("addComment", lineItem, null));
if (diffLine.getAction() == ADD) {
if (lineItem.getIndex() == 0 || diffs.get(lineItem.getIndex()-1).getAction() == EQUAL)
@@ -647,6 +645,13 @@ public class TextDiffPanel extends Panel {
}
});
+
+ String cssClass;
+ if (change.contains(change.getConcernedComment()))
+ cssClass = ".concerned-comments";
+ else
+ cssClass = ".diff-block:first";
+ autoScrollScript = String.format("pmease.commons.scroll.next('%s', %d);", cssClass, SCROLL_MARGIN);
}
private void showComments(AjaxRequestTarget target) {
@@ -687,9 +692,12 @@ public class TextDiffPanel extends Panel {
private final ListItem<DiffLine> item;
- public AddCommentLink(String id, ListItem<DiffLine> item) {
+ private final CommitComment replyComment;
+
+ public AddCommentLink(String id, ListItem<DiffLine> item, CommitComment replyComment) {
super(id);
this.item = item;
+ this.replyComment = replyComment;
}
@Override
@@ -701,8 +709,14 @@ public class TextDiffPanel extends Panel {
Form<?> form = new Form<Void>("form");
form.setOutputMarkupId(true);
+ String content = "";
+ if (replyComment != null) {
+ for (String line: Splitter.on('\n').split(replyComment.getContent()))
+ content += "> " + line + "\n";
+ }
+
final CommentInput input;
- form.add(input = new CommentInput("input", Model.of("")));
+ form.add(input = new CommentInput("input", Model.of(content)));
final WebMarkupContainer contentRow = (WebMarkupContainer) item.get(CONTENT_ROW_ID);
final WebMarkupContainer commentsRow = (WebMarkupContainer) item.get(COMMENTS_ROW_ID);
@@ -734,37 +748,37 @@ public class TextDiffPanel extends Panel {
comment.setUser(currentUser);
String commit;
CommentPosition position;
- if (diffLine.getAction() == DELETE) {
- commit = change.getOldRevision();
- position = new CommentPosition(change.getOldPath(), diffLine.getOldLineNo());
- } else if (diffLine.getAction() == ADD) {
- commit = change.getNewRevision();
- position = new CommentPosition(change.getNewPath(), diffLine.getNewLineNo());
+ if (replyComment != null) {
+ commit = replyComment.getCommit();
+ position = replyComment.getPosition();
} else {
List<CommitComment> comments = getLineComments(diffLine);
- if (comments.isEmpty()) {
- if (getNewComments() != null) {
- commit = change.getNewRevision();
- position = new CommentPosition(change.getNewPath(), diffLine.getNewLineNo());
- } else {
- commit = change.getOldRevision();
- position = new CommentPosition(change.getOldPath(), diffLine.getOldLineNo());
- }
- } else {
+ if (!comments.isEmpty()) {
CommitComment lastComment = comments.get(comments.size()-1);
commit = lastComment.getCommit();
position = lastComment.getPosition();
- }
+ } else if (diffLine.getAction() == DELETE) {
+ commit = change.getOldRevision();
+ position = new CommentPosition(change.getOldPath(), diffLine.getOldLineNo());
+ } else if (diffLine.getAction() == ADD) {
+ commit = change.getNewRevision();
+ position = new CommentPosition(change.getNewPath(), diffLine.getNewLineNo());
+ } else if (getNewComments() != null) {
+ commit = change.getNewRevision();
+ position = new CommentPosition(change.getNewPath(), diffLine.getNewLineNo());
+ } else {
+ commit = change.getOldRevision();
+ position = new CommentPosition(change.getOldPath(), diffLine.getOldLineNo());
+ }
}
+
comment.setCommit(commit);
comment.setPosition(position);
comment.setContent(input.getModelObject());
comment.setCommentDate(new Date());
comment.setCommitDate(repoModel.getObject().getCommit(commit).getCommitter().getWhen());
- if (commit.equals(change.getOldRevision()))
- comment.setNewCommit(change.getNewRevision());
- else
- comment.setOldCommit(change.getOldRevision());
+ comment.setNewCommit(change.getNewRevision());
+ comment.setOldCommit(change.getOldRevision());
change.saveComment(comment);
@@ -809,14 +823,14 @@ public class TextDiffPanel extends Panel {
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
-
- String cssClass;
- if (change.contains(change.getConcernedComment()))
- cssClass = ".concerned-comments";
- else
- cssClass = ".diff-block:first";
- String script = String.format("pmease.commons.scroll.next('%s', %d);", cssClass, SCROLL_MARGIN);
- response.render(OnDomReadyHeaderItem.forScript(script));
+
+ // only auto-scroll this panel once after it is created; otherwise page refreshing
+ // caused by actions such as integrate/discard on request compare page will also
+ // get scrolled
+ if (autoScrollScript != null) {
+ response.render(OnDomReadyHeaderItem.forScript(autoScrollScript));
+ autoScrollScript = null;
+ }
}
private Map<Integer, List<CommitComment>> getOldComments() {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/NewRequestPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/NewRequestPage.java
index 2b2433f66f..e3d3263f89 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/NewRequestPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/NewRequestPage.java
@@ -277,7 +277,7 @@ public class NewRequestPage extends RepositoryInfoPage implements CommitComments
@Override
public void onClick() {
- PageParameters params = RequestDetailPage.params4(pullRequest);
+ PageParameters params = RequestDetailPage.paramsOf(pullRequest);
setResponsePage(RequestActivitiesPage.class, params);
}
@@ -354,7 +354,7 @@ public class NewRequestPage extends RepositoryInfoPage implements CommitComments
GitPlex.getInstance(PullRequestManager.class).send(pullRequest);
- setResponsePage(OpenRequestsPage.class, paramsOf(pullRequest.getTarget().getRepository()));
+ setResponsePage(RequestActivitiesPage.class, RequestActivitiesPage.paramsOf(pullRequest));
}
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestComparePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestComparePage.java
index fbdb747ddf..37d325fd99 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestComparePage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestComparePage.java
@@ -35,6 +35,8 @@ import org.eclipse.jgit.lib.FileMode;
import org.hibernate.Hibernate;
import com.google.common.base.Preconditions;
+import com.pmease.commons.git.BlobInfo;
+import com.pmease.commons.git.BlobText;
import com.pmease.commons.git.Change;
import com.pmease.commons.git.Commit;
import com.pmease.commons.git.GitUtils;
@@ -49,7 +51,9 @@ import com.pmease.commons.wicket.behavior.menu.MenuBehavior;
import com.pmease.commons.wicket.behavior.menu.MenuItem;
import com.pmease.commons.wicket.behavior.menu.MenuPanel;
import com.pmease.gitplex.core.GitPlex;
+import com.pmease.gitplex.core.comment.BlobLoader;
import com.pmease.gitplex.core.comment.CommentAwareChange;
+import com.pmease.gitplex.core.comment.CommentLoader;
import com.pmease.gitplex.core.model.CommitComment;
import com.pmease.gitplex.core.model.IntegrationInfo;
import com.pmease.gitplex.core.model.PullRequest;
@@ -141,7 +145,8 @@ public class RequestComparePage extends RequestDetailPage {
IntegrationInfo integrationInfo = request.getIntegrationInfo();
if (request.isOpen()
&& integrationInfo.getIntegrationHead() != null
- && !integrationInfo.getIntegrationHead().equals(integrationInfo.getRequestHead())) {
+ && !integrationInfo.getIntegrationHead().equals(integrationInfo.getRequestHead())
+ && integrationInfo.hasChanges()) {
Commit commit = getRepository().git().showRevision(request.getIntegrationInfo().getIntegrationHead());
choices.put(request.getIntegrationInfo().getIntegrationHead(),
new CommitDescription("Integration Preview", commit.getSubject()));
@@ -283,7 +288,7 @@ public class RequestComparePage extends RequestDetailPage {
if (getConcernedComment() != null) {
final String latestCommit = getPullRequest().getLatestUpdate().getHeadCommit();
if (!getConcernedComment().getCommit().equals(latestCommit)) {
- items.add(new ComparisonChoiceItem("Concerned", "Latest") {
+ items.add(new ComparisonChoiceItem("Concerned", "Latest Update") {
@Override
protected void onSelect() {
@@ -308,7 +313,7 @@ public class RequestComparePage extends RequestDetailPage {
});
}
}
- items.add(new ComparisonChoiceItem("Base", "Latest") {
+ items.add(new ComparisonChoiceItem("Base", "Latest Update") {
@Override
protected void onSelect() {
@@ -324,8 +329,9 @@ public class RequestComparePage extends RequestDetailPage {
final IntegrationInfo integrationInfo = getPullRequest().getIntegrationInfo();
if (getPullRequest().isOpen()
&& integrationInfo.getIntegrationHead() != null
- && !integrationInfo.getIntegrationHead().equals(integrationInfo.getRequestHead())) {
- items.add(new ComparisonChoiceItem("Latest", "Integration Preview") {
+ && !integrationInfo.getIntegrationHead().equals(integrationInfo.getRequestHead())
+ && integrationInfo.hasChanges()) {
+ items.add(new ComparisonChoiceItem("Latest Update", "Integration Preview") {
@Override
protected void onSelect() {
@@ -489,12 +495,10 @@ public class RequestComparePage extends RequestDetailPage {
newCommit = getPullRequest().getLatestUpdate().getHeadCommit();
} else {
filePath = comment.getPosition().getFilePath();
- if (commitsModel.getObject().containsKey(comment.getOldCommit())) {
+ if (commitsModel.getObject().containsKey(comment.getOldCommit())
+ && commitsModel.getObject().containsKey(comment.getNewCommit())) {
oldCommit = comment.getOldCommit();
- newCommit = comment.getCommit();
- } else if (commitsModel.getObject().containsKey(comment.getNewCommit())) {
newCommit = comment.getNewCommit();
- oldCommit = comment.getCommit();
} else if (!comment.getCommit().equals(getPullRequest().getLatestUpdate().getHeadCommit())) {
oldCommit = comment.getCommit();
newCommit = getPullRequest().getLatestUpdate().getHeadCommit();
@@ -502,6 +506,7 @@ public class RequestComparePage extends RequestDetailPage {
oldCommit = getPullRequest().getBaseCommit();
newCommit = comment.getCommit();
}
+
change = resolveChange(filePath);
}
if (change == null && !getChanges().isEmpty()) {
@@ -580,7 +585,7 @@ public class RequestComparePage extends RequestDetailPage {
public static PageParameters paramsOf(PullRequest request, @Nullable String oldCommit,
@Nullable String newCommit, @Nullable String filePath, @Nullable CommitComment concernedComment) {
- PageParameters params = RequestDetailPage.params4(request);
+ PageParameters params = RequestDetailPage.paramsOf(request);
if (oldCommit != null)
params.set("original", oldCommit);
@@ -595,10 +600,30 @@ public class RequestComparePage extends RequestDetailPage {
}
private CommentAwareChange loadComments(RevAwareChange change) {
- boolean enableOldComments = getPullRequest().getCommits().contains(change.getOldRevision());
- boolean enableNewComments = getPullRequest().getCommits().contains(change.getNewRevision());
- return new CommentAwareChange(getRepository(), change, enableOldComments,
- enableNewComments, getConcernedComment());
+ BlobLoader blobLoader = new BlobLoader() {
+
+ @Override
+ public List<String> loadBlob(BlobInfo blobInfo) {
+ BlobText blobText = repoModel.getObject().getBlobText(blobInfo);
+ return blobText!=null?blobText.getLines():null;
+ }
+
+ };
+ CommentLoader commentLoader = new CommentLoader() {
+
+ @Override
+ public List<CommitComment> loadComments(String commit) {
+ List<CommitComment> comments = getPullRequest().getCommitComments().get(commit);
+ if (comments == null)
+ return new ArrayList<>();
+ else
+ return comments;
+ }
+
+ };
+
+ return new CommentAwareChange(change, getPullRequest().getCommits(),
+ commentLoader, blobLoader, getConcernedComment());
}
@Override
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestDetailPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestDetailPage.java
index 2d235a823b..b150c7acd2 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestDetailPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestDetailPage.java
@@ -537,7 +537,8 @@ public abstract class RequestDetailPage extends RepositoryInfoPage implements Co
null, null);
Link<Void> link = new BookmarkablePageLink<Void>("preview", RequestComparePage.class, params);
- link.setVisible(!integrationInfo.getIntegrationHead().equals(integrationInfo.getRequestHead()));
+ link.setVisible(!integrationInfo.getIntegrationHead().equals(integrationInfo.getRequestHead())
+ && integrationInfo.hasChanges());
fragment.add(link);
DropdownPanel verificationDetails = new DropdownPanel("verificationDetails") {
@@ -606,7 +607,7 @@ public abstract class RequestDetailPage extends RepositoryInfoPage implements Co
return false;
}
- public static PageParameters params4(PullRequest request) {
+ public static PageParameters paramsOf(PullRequest request) {
PageParameters params = RepositoryInfoPage.paramsOf(request.getTarget().getRepository());
params.set("request", request.getId());
return params;
@@ -624,7 +625,7 @@ public abstract class RequestDetailPage extends RepositoryInfoPage implements Co
@Override
protected Link<?> newLink(String linkId, Class<? extends Page> pageClass) {
- return new BookmarkablePageLink<Void>(linkId, pageClass, params4(getPullRequest()));
+ return new BookmarkablePageLink<Void>(linkId, pageClass, paramsOf(getPullRequest()));
}
};
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestSummaryPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestSummaryPanel.java
index 9a9b086c0e..d4adc36550 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestSummaryPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/pullrequest/RequestSummaryPanel.java
@@ -32,7 +32,7 @@ public class RequestSummaryPanel extends Panel {
@Override
public void onClick() {
- setResponsePage(RequestActivitiesPage.class, RequestActivitiesPage.params4(getPullRequest()));
+ setResponsePage(RequestActivitiesPage.class, RequestActivitiesPage.paramsOf(getPullRequest()));
}
};