diff options
author | David Pursehouse <dpursehouse@collab.net> | 2019-07-05 16:49:46 +0900 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2019-07-05 16:49:46 +0900 |
commit | bd049d9dc5af77d7f23d41eefa33cf6d4cdd4615 (patch) | |
tree | 1e055781b3f2a408f58204cabc44a68e006b1ffd | |
parent | c163ad7bd0a97368c04055449c1ab6da78575b82 (diff) | |
parent | 58b2c5487e8791fd62c6e25c71f69d1f8ff5f978 (diff) |
Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
PatchFile: Fix getting comment context for left side
Revert "Allow load labels to cross package boundaries by default"
CommentSender: Add line number in debug log
Change-Id: I7cc5200a389bd4ff62a399537e74bb753e733be2
-rw-r--r-- | .bazelrc | 1 | ||||
-rw-r--r-- | java/com/google/gerrit/server/mail/send/CommentSender.java | 3 | ||||
-rw-r--r-- | java/com/google/gerrit/server/patch/PatchFile.java | 12 | ||||
-rw-r--r-- | javatests/com/google/gerrit/acceptance/server/change/CommentsIT.java | 27 |
4 files changed, 30 insertions, 13 deletions
@@ -4,7 +4,6 @@ build --experimental_strict_action_env build --action_env=PATH build --disk_cache=~/.gerritcodereview/bazel-cache/cas build --java_toolchain //tools:error_prone_warnings_toolchain -build --incompatible_disallow_load_labels_to_cross_package_boundaries=false test --build_tests_only test --test_output=errors diff --git a/java/com/google/gerrit/server/mail/send/CommentSender.java b/java/com/google/gerrit/server/mail/send/CommentSender.java index e78a60a215..90f43d8a69 100644 --- a/java/com/google/gerrit/server/mail/send/CommentSender.java +++ b/java/com/google/gerrit/server/mail/send/CommentSender.java @@ -535,7 +535,8 @@ public class CommentSender extends ReplyToChangeSender { } catch (IndexOutOfBoundsException err) { // Default to the empty string if the given line number does not appear // in the file. - logger.atFine().withCause(err).log("Failed to get line number of file on side %d", side); + logger.atFine().withCause(err).log( + "Failed to get line number %d of file on side %d", lineNbr, side); return ""; } catch (NoSuchEntityException err) { // Default to the empty string if the side cannot be found. diff --git a/java/com/google/gerrit/server/patch/PatchFile.java b/java/com/google/gerrit/server/patch/PatchFile.java index aff519abfa..024fef4f48 100644 --- a/java/com/google/gerrit/server/patch/PatchFile.java +++ b/java/com/google/gerrit/server/patch/PatchFile.java @@ -87,6 +87,14 @@ public class PatchFile { } } + private String getOldName() { + String name = entry.getOldName(); + if (name != null) { + return name; + } + return entry.getNewName(); + } + /** * Extract a line from the file, as a string. * @@ -100,7 +108,7 @@ public class PatchFile { switch (file) { case 0: if (a == null) { - a = load(aTree, entry.getOldName()); + a = load(aTree, getOldName()); } return a.getString(line - 1); @@ -127,7 +135,7 @@ public class PatchFile { switch (file) { case 0: if (a == null) { - a = load(aTree, entry.getOldName()); + a = load(aTree, getOldName()); } return a.size(); diff --git a/javatests/com/google/gerrit/acceptance/server/change/CommentsIT.java b/javatests/com/google/gerrit/acceptance/server/change/CommentsIT.java index 535d461874..61dbf24df3 100644 --- a/javatests/com/google/gerrit/acceptance/server/change/CommentsIT.java +++ b/javatests/com/google/gerrit/acceptance/server/change/CommentsIT.java @@ -532,6 +532,13 @@ public class CommentsIT extends AbstractDaemonTest { @Test public void publishCommentsAllRevisions() throws Exception { + PushOneCommit.Result result = createChange(); + String changeId = result.getChangeId(); + + pushFactory + .create(db, admin.getIdent(), testRepo, SUBJECT, FILE_NAME, "initial content\n", changeId) + .to("refs/heads/master"); + PushOneCommit.Result r1 = pushFactory .create(db, admin.getIdent(), testRepo, SUBJECT, FILE_NAME, "old boring content\n") @@ -556,7 +563,7 @@ public class CommentsIT extends AbstractDaemonTest { addDraft( r1.getChangeId(), r1.getCommit().getName(), - newDraft(FILE_NAME, Side.PARENT, 2, "what happened to this?")); + newDraft(FILE_NAME, Side.PARENT, createLineRange(1, 0, 7), "what happened to this?")); addDraft( r2.getChangeId(), r2.getCommit().getName(), @@ -641,8 +648,8 @@ public class CommentsIT extends AbstractDaemonTest { + project.get() + "/+/" + c - + "/1/a.txt@a2 \n" - + "PS1, Line 2: \n" + + "/1/a.txt@a1 \n" + + "PS1, Line 1: initial\n" + "what happened to this?\n" + "\n" + "\n" @@ -670,7 +677,7 @@ public class CommentsIT extends AbstractDaemonTest { + "/+/" + c + "/2/a.txt@a1 \n" - + "PS2, Line 1: \n" + + "PS2, Line 1: initial content\n" + "comment 1 on base\n" + "\n" + "\n" @@ -700,7 +707,7 @@ public class CommentsIT extends AbstractDaemonTest { + "/+/" + c + "/2/a.txt@2 \n" - + "PS2, Line 2: nten\n" + + "PS2, Line 2: cntent\n" + "typo: content\n" + "\n" + "\n"); @@ -1135,7 +1142,7 @@ public class CommentsIT extends AbstractDaemonTest { private DraftInput newDraft(String path, Side side, Comment.Range range, String message) { DraftInput d = new DraftInput(); - return populate(d, path, side, null, range, message, false); + return populate(d, path, side, null, range.startLine, range, message, false); } private DraftInput newDraftOnParent(String path, int parent, int line, String message) { @@ -1148,23 +1155,25 @@ public class CommentsIT extends AbstractDaemonTest { String path, Side side, Integer parent, + int line, Comment.Range range, String message, Boolean unresolved) { - int line = range.startLine; c.path = path; c.side = side; c.parent = parent; c.line = line != 0 ? line : null; c.message = message; c.unresolved = unresolved; - if (line != 0) c.range = range; + if (range != null) { + c.range = range; + } return c; } private static <C extends Comment> C populate( C c, String path, Side side, Integer parent, int line, String message, Boolean unresolved) { - return populate(c, path, side, parent, createLineRange(line, 1, 5), message, unresolved); + return populate(c, path, side, parent, line, null, message, unresolved); } private static Comment.Range createLineRange(int line, int startChar, int endChar) { |