From cbd679e61096babeeb33560a88b13baa45679c7c Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 10 Nov 2015 23:18:41 -0800 Subject: [PATCH 1/4] BanCommitCommand: Do not use commons.collections Bug: Issue 3662 Change-Id: I7d6656f71fe9dea1b93a3f2fcc247104f7848f1a --- gerrit-sshd/BUCK | 1 - .../java/com/google/gerrit/sshd/commands/BanCommitCommand.java | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/gerrit-sshd/BUCK b/gerrit-sshd/BUCK index f4ff65bc29..701ef4dd6a 100644 --- a/gerrit-sshd/BUCK +++ b/gerrit-sshd/BUCK @@ -20,7 +20,6 @@ java_library( '//lib:jsch', '//lib/auto:auto-value', '//lib/commons:codec', - '//lib/commons:collections', '//lib/guice:guice', '//lib/guice:guice-assistedinject', '//lib/guice:guice-servlet', # SSH should not depend on servlet diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/BanCommitCommand.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/BanCommitCommand.java index 647d28d650..485d10f2db 100644 --- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/BanCommitCommand.java +++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/BanCommitCommand.java @@ -28,7 +28,6 @@ import com.google.gerrit.sshd.CommandMetaData; import com.google.gerrit.sshd.SshCommand; import com.google.inject.Inject; -import org.apache.commons.collections.CollectionUtils; import org.eclipse.jgit.lib.ObjectId; import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.Option; @@ -77,7 +76,7 @@ public class BanCommitCommand extends SshCommand { } private void printCommits(List commits, String message) { - if (CollectionUtils.isNotEmpty(commits)) { + if (commits != null && !commits.isEmpty()) { stdout.print(message + ":\n"); stdout.print(Joiner.on(",\n").join(commits)); stdout.print("\n\n"); From 47584c7f654ce040caaa9ba5104a7d712b3ab464 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Wed, 11 Nov 2015 05:42:41 -0800 Subject: [PATCH 2/4] InlineEdit: Enable inline comments retrieval in change screen Inline comments retrieval was erroneously disabled in change screen. While drafts cannot be created and published on change edits, comments from the based patch set should be shown. Activate this code path again and filter the file table for the patch set, the change edit is based on. Bug: Issue 3659 Change-Id: I6781f1e46174466165b7091a7311808e39a55fbc --- .../com/google/gerrit/client/change/ChangeScreen.java | 7 ++++++- .../com/google/gerrit/client/changes/ChangeInfo.java | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/ChangeScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/ChangeScreen.java index 8b29f86efb..83514dc119 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/ChangeScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/ChangeScreen.java @@ -785,7 +785,12 @@ public class ChangeScreen extends Screen { CallbackGroup group = new CallbackGroup(); Timestamp lastReply = myLastReply(info); if (rev.is_edit()) { - loadFileList(b, rev, lastReply, group, null, null); + // Comments are filtered for the current revision. Use parent + // patch set for edits, as edits themself can never have comments. + RevisionInfo p = RevisionInfo.findEditParentRevision( + info.revisions().values()); + List>> comments = loadComments(p, group); + loadFileList(b, rev, lastReply, group, comments, null); } else { loadDiff(b, rev, lastReply, group); } diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeInfo.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeInfo.java index fff792ff84..f5d5ffecd3 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeInfo.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/changes/ChangeInfo.java @@ -279,6 +279,12 @@ public class ChangeInfo extends JavaScriptObject { } public static int findEditParent(JsArray list) { + RevisionInfo r = findEditParentRevision(list); + return r == null ? -1 : r._number(); + } + + public static RevisionInfo findEditParentRevision( + JsArray list) { for (int i = 0; i < list.length(); i++) { // edit under revisions? RevisionInfo editInfo = list.get(i); @@ -290,12 +296,12 @@ public class ChangeInfo extends JavaScriptObject { String name = parentInfo.name(); if (name.equals(parentRevision)) { // found parent pacth set number - return parentInfo._number(); + return parentInfo; } } } } - return -1; + return null; } public final String id() { From 5decdb25e952d440094aa39a07b65f0ea9e406d7 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Wed, 11 Nov 2015 09:01:02 -0800 Subject: [PATCH 3/4] ChangeHookValidator: Fix old revision retrieval for root commit onCommitReceived should not try to get the parent for the first commit in an empty repository. Bug: Issue 3666 Change-Id: Ib8ce3d69dc3dfce3ea9aec9315315f266c589eef --- .../gerrit/server/git/validators/CommitValidators.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java b/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java index facfb6be14..fc8658f1b6 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/git/validators/CommitValidators.java @@ -551,8 +551,10 @@ public class CommitValidators { IdentifiedUser user = (IdentifiedUser) refControl.getCurrentUser(); String refname = receiveEvent.refName; - ObjectId old = receiveEvent.commit.getParent(0); - + ObjectId old = ObjectId.zeroId(); + if (receiveEvent.commit.getParentCount() > 0) { + old = receiveEvent.commit.getParent(0); + } if (receiveEvent.command.getRefName().startsWith(REFS_CHANGES)) { /* * If the ref-update hook tries to distinguish behavior between pushes to From 850d8de460d3177f51e90dd4bcdfd6c6967dee9c Mon Sep 17 00:00:00 2001 From: Nadav Samet Date: Fri, 16 Oct 2015 22:41:18 -0700 Subject: [PATCH 4/4] AccountManager: Update display name only if it is not null. During account linking initiated by the HttpLoginServlet, the code overrides the user's display name with null. This commit ensures that overriding the display name can only be done when the provided value is not null. Bug: Issue 3612 Change-Id: I8f47f5025349a244e2110aac902b44285cf8ad35 --- .../java/com/google/gerrit/server/account/AccountManager.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountManager.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountManager.java index 62615c6a2c..e1033d0022 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountManager.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/AccountManager.java @@ -14,6 +14,7 @@ package com.google.gerrit.server.account; +import com.google.common.base.Strings; import com.google.gerrit.audit.AuditService; import com.google.gerrit.common.TimeUtil; import com.google.gerrit.common.data.AccessSection; @@ -158,6 +159,7 @@ public class AccountManager { } if (!realm.allowsEdit(Account.FieldName.FULL_NAME) + && !Strings.isNullOrEmpty(who.getDisplayName()) && !eq(user.getAccount().getFullName(), who.getDisplayName())) { toUpdate = load(toUpdate, user.getAccountId(), db); toUpdate.setFullName(who.getDisplayName());