From 2f0ec10599d4e99190ce6b4483eec8b38efd8856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20=C5=BDivkov?= Date: Tue, 17 Apr 2018 10:58:24 +0200 Subject: [PATCH 1/9] Set version to 2.13.12-SNAPSHOT Change-Id: Ia1b4c0ddad3744a537cef1b3853d5b0dc2086a4e --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index c20a4cb909..3b4e27482b 100644 --- a/VERSION +++ b/VERSION @@ -2,4 +2,4 @@ # Used by :api_install and :api_deploy targets # when talking to the destination repository. # -GERRIT_VERSION = '2.13.11' +GERRIT_VERSION = '2.13.12-SNAPSHOT' From 5489ad4b31b117fe5ec557f8ffb85099e8f965d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C5=A1a=20=C5=BDivkov?= Date: Tue, 28 Nov 2017 12:56:11 +0100 Subject: [PATCH 2/9] Add ProjectCache.remove(Project.NameKey name) method Until now we only had ProjectCache.remove(Project p) which requires a project instance. This could be a problem when running Gerrit HA in active/active mode and a project name has to be removed from the project-list cache on the other node. The project may not exist at that point in time (because it was just deleted) and trying to load a Project instance would lead to an error which would prevent removing this project's name from the project_list cache. Change-Id: Ida124ea95bb2cb776adbf8bd4d2bb77c0bdbbeaa --- .../com/google/gerrit/server/project/ProjectCache.java | 6 ++++++ .../google/gerrit/server/project/ProjectCacheImpl.java | 9 +++++++-- .../com/google/gerrit/server/project/RefControlTest.java | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectCache.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectCache.java index 67bdc88c57..fa2f639279 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectCache.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectCache.java @@ -59,6 +59,12 @@ public interface ProjectCache { */ void remove(Project p); + /** + * Remove information about the given project from the cache. It will no longer be returned from + * {@link #all()}. + */ + void remove(Project.NameKey name); + /** @return sorted iteration of projects. */ Iterable all(); diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectCacheImpl.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectCacheImpl.java index 8a08052a87..7ce19c8f42 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectCacheImpl.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectCacheImpl.java @@ -183,17 +183,22 @@ public class ProjectCacheImpl implements ProjectCache { @Override public void remove(final Project p) { + remove(p.getNameKey()); + } + + @Override + public void remove(Project.NameKey name) { listLock.lock(); try { SortedSet n = Sets.newTreeSet(list.get(ListKey.ALL)); - n.remove(p.getNameKey()); + n.remove(name); list.put(ListKey.ALL, Collections.unmodifiableSortedSet(n)); } catch (ExecutionException e) { log.warn("Cannot list avaliable projects", e); } finally { listLock.unlock(); } - evict(p); + evict(name); } @Override diff --git a/gerrit-server/src/test/java/com/google/gerrit/server/project/RefControlTest.java b/gerrit-server/src/test/java/com/google/gerrit/server/project/RefControlTest.java index d4d77bddc8..c04c474cd3 100644 --- a/gerrit-server/src/test/java/com/google/gerrit/server/project/RefControlTest.java +++ b/gerrit-server/src/test/java/com/google/gerrit/server/project/RefControlTest.java @@ -269,6 +269,9 @@ public class RefControlTest { public void remove(Project p) { } + @Override + public void remove(Project.NameKey name) {} + @Override public Iterable all() { return Collections.emptySet(); From ef335f6518790268f5c10ad522b432dd3fa1854d Mon Sep 17 00:00:00 2001 From: Edwin Kempin Date: Mon, 26 Mar 2018 11:14:49 +0200 Subject: [PATCH 3/9] GetAuditLog: Fix NPE if group UUID cannot be resolved A group UUID cannot be resolved if there is no groupback that handles it. This can e.g. happen if the singleusergroup was used and single user groups have been added to Gerrit groups, but then the singleusergroup plugin was uninstalled. Change-Id: I87b83c3904172e8ff32cfd07c15e9a9951921c71 Signed-off-by: Edwin Kempin (cherry picked from commit 3e20db09ec088158a255eb6cd5d3d770a2ecfaee) --- .../main/java/com/google/gerrit/server/group/GetAuditLog.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/group/GetAuditLog.java b/gerrit-server/src/main/java/com/google/gerrit/server/group/GetAuditLog.java index e29b37f40e..09aad6c2ab 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/group/GetAuditLog.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/group/GetAuditLog.java @@ -108,7 +108,9 @@ public class GetAuditLog implements RestReadView { GroupDescription.Basic groupDescription = groupBackend.get(includedGroupUUID); member = new GroupInfo(); member.id = Url.encode(includedGroupUUID.get()); - member.name = groupDescription.getName(); + if (groupDescription != null) { + member.name = groupDescription.getName(); + } } auditEvents.add( From 5cb9186480d0e42a38616e74ae256d5e03f338b4 Mon Sep 17 00:00:00 2001 From: Edwin Kempin Date: Mon, 26 Mar 2018 10:54:49 +0200 Subject: [PATCH 4/9] AccountGroupAuditLogScreen: Display group UUID if group name is missing The group name is missing if there is no group backend that can resolve the UUID. This can e.g. happen if the singleusergroup was used and single user groups have been added to Gerrit groups, but then the singleusergroup plugin was uninstalled so that the single user groups can no longer be resolved. Change-Id: I1bccec4bb38b55f6ad9b2d2ac83227b379d09071 Signed-off-by: Edwin Kempin (cherry picked from commit 92f58f80b1eb8f763266d96a9be0705a2535b178) --- .../client/admin/AccountGroupAuditLogScreen.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AccountGroupAuditLogScreen.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AccountGroupAuditLogScreen.java index b056afa9e2..5e38a1414f 100644 --- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AccountGroupAuditLogScreen.java +++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/admin/AccountGroupAuditLogScreen.java @@ -113,17 +113,19 @@ public class AccountGroupAuditLogScreen extends AccountGroupScreen { GroupInfo member = auditEvent.memberAsGroup(); if (AccountGroup.isInternalGroup(member.getGroupUUID())) { table.setWidget( - row, 3, new Hyperlink(member.name(), Dispatcher.toGroup(member.getGroupUUID()))); + row, + 3, + new Hyperlink(formatGroup(member), Dispatcher.toGroup(member.getGroupUUID()))); fmt.getElement(row, 3).setTitle(null); } else if (member.url() != null) { Anchor a = new Anchor(); - a.setText(member.name()); + a.setText(formatGroup(member)); a.setHref(member.url()); a.setTitle("UUID " + member.getGroupUUID().get()); table.setWidget(row, 3, a); fmt.getElement(row, 3).setTitle(null); } else { - table.setText(row, 3, member.name()); + table.setText(row, 3, formatGroup(member)); fmt.getElement(row, 3).setTitle("UUID " + member.getGroupUUID().get()); } break; @@ -148,4 +150,10 @@ public class AccountGroupAuditLogScreen extends AccountGroupScreen { b.append(")"); return b.toString(); } + + private static String formatGroup(GroupInfo group) { + return group.name() != null && !group.name().isEmpty() + ? group.name() + : group.getGroupUUID().get(); + } } From a3cd22efee5ff9d7bf414695df60c75b5b1b1856 Mon Sep 17 00:00:00 2001 From: Edwin Kempin Date: Tue, 27 Mar 2018 09:24:54 +0200 Subject: [PATCH 5/9] Docs: Clarify that for external groups the name in GroupInfo can be missing For external groups the group name is missing if there is no group backend that can resolve the group UUID. E.g. this can happen when a plugin that provided a group backend was uninstalled (e.g. the singleusergroup plugin). Change-Id: I0d7f7253698c0125d7692781fa32f4294cda3bcc Signed-off-by: Edwin Kempin (cherry picked from commit 219e797144d7e6425373bd35c7fa1f48b8ac4abb) --- Documentation/rest-api-groups.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/rest-api-groups.txt b/Documentation/rest-api-groups.txt index 378c7f5380..61b746d8bd 100644 --- a/Documentation/rest-api-groups.txt +++ b/Documentation/rest-api-groups.txt @@ -1404,8 +1404,11 @@ a Gerrit internal group, or an external group that is known to Gerrit. |Field Name ||Description |`id` ||The URL encoded UUID of the group. |`name` | -not set if returned in a map where the group name is used as map key| -The name of the group. +optional, not set if returned in a map where the group name is used as map key| +The name of the group. + +For external groups the group name is missing if there is no group +backend that can resolve the group UUID. E.g. this can happen when a +plugin that provided a group backend was uninstalled. |`url` |optional| URL to information about the group. Typically a URL to a web page that permits users to apply to join the group, or manage their membership. From ebf9f4ef24fead0ab98e387996a674ce86b729aa Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 17 Apr 2018 12:07:34 +0200 Subject: [PATCH 6/9] AbstractElasticIndex: Open XContentBuilder in try-with-resource Change-Id: I6f1de6573bf0c1e8932f96c4c4c1a819a955fbb1 --- .../elasticsearch/AbstractElasticIndex.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/gerrit-elasticsearch/src/main/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java b/gerrit-elasticsearch/src/main/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java index a60c552c25..adb1687c47 100644 --- a/gerrit-elasticsearch/src/main/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java +++ b/gerrit-elasticsearch/src/main/java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java @@ -161,20 +161,23 @@ abstract class AbstractElasticIndex implements Index { } private String toDoc(V v) throws IOException { - XContentBuilder builder = jsonBuilder().startObject(); - for (Values values : schema.buildFields(v, fillArgs)) { - String name = values.getField().getName(); - if (values.getField().isRepeatable()) { - builder.field( - name, - Streams.stream(values.getValues()).filter(e -> shouldAddElement(e)).collect(toList())); - } else { - Object element = Iterables.getOnlyElement(values.getValues(), ""); - if (shouldAddElement(element)) { - builder.field(name, element); + try (XContentBuilder builder = jsonBuilder().startObject()) { + for (Values values : schema.buildFields(v, fillArgs)) { + String name = values.getField().getName(); + if (values.getField().isRepeatable()) { + builder.field( + name, + Streams.stream(values.getValues()) + .filter(e -> shouldAddElement(e)) + .collect(toList())); + } else { + Object element = Iterables.getOnlyElement(values.getValues(), ""); + if (shouldAddElement(element)) { + builder.field(name, element); + } } } + return builder.endObject().string(); } - return builder.endObject().string(); } } From 789bb29b895050ccb5ff243649f2518ce5ee62e0 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 17 Apr 2018 13:56:18 +0200 Subject: [PATCH 7/9] Clarify behavior of ownerin: and reviewerin: predicates When the ownerin: or reviewerin: predicate is used in a query without any additional explicit index predicate, it will default to only include changes in status 'OPEN'. Clarify this in the documentation, and expand the tests to show this behavior. Bug: Issue 8597 Change-Id: Iddf66a44e0bcbc00f97466a997025abc3d82b90f --- Documentation/user-search.txt | 8 ++++++-- .../server/query/change/AbstractQueryChangesTest.java | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Documentation/user-search.txt b/Documentation/user-search.txt index 2902d58414..6806cca871 100644 --- a/Documentation/user-search.txt +++ b/Documentation/user-search.txt @@ -109,7 +109,9 @@ Changes originally submitted by 'USER'. The special case of [[ownerin]] ownerin:'GROUP':: + -Changes originally submitted by a user in 'GROUP'. +Changes originally submitted by a user in 'GROUP'. When no other index +predicate is explicitly added in the query, defaults to only include +changes in status 'OPEN'. [[query]] query:'NAME':: @@ -133,7 +135,9 @@ will find changes where the caller has been CC'ed. [[reviewerin]] reviewerin:'GROUP':: + -Changes that have been, or need to be, reviewed by a user in 'GROUP'. +Changes that have been, or need to be, reviewed by a user in 'GROUP'. When +no other index predicate is explicitly added in the query, defaults to only +include changes in status 'OPEN'. [[commit]] commit:'SHA1':: diff --git a/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java b/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java index 0178cd3404..d2004f11da 100644 --- a/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java +++ b/gerrit-server/src/test/java/com/google/gerrit/server/query/change/AbstractQueryChangesTest.java @@ -513,6 +513,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests { assertQuery("ownerin:Administrators", change1); assertQuery("ownerin:\"Registered Users\"", change2, change1); + assertQuery("ownerin:\"Registered Users\" project:repo", change3, change2, change1); assertQuery("ownerin:\"Registered Users\" status:merged", change3); } @@ -1749,6 +1750,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests { gApi.changes().id(change2.getId().get()).current().submit(); assertQuery("reviewerin:" + group); + assertQuery("project:repo reviewerin:" + group, change2); assertQuery("status:merged reviewerin:" + group, change2); } From 703fc33df2ed04e774ceec1003dee1b71e4d46d9 Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 17 Apr 2018 14:24:33 +0200 Subject: [PATCH 8/9] Set 2.13.12-SNAPSHOT in pom.xml and plugin documentation Change-Id: Idcd310e9bd29b61eb0d1ee3f5bdf87053cf7a9cc --- Documentation/dev-plugins.txt | 2 +- gerrit-acceptance-framework/pom.xml | 2 +- gerrit-extension-api/pom.xml | 2 +- gerrit-plugin-api/pom.xml | 2 +- gerrit-plugin-archetype/pom.xml | 2 +- gerrit-plugin-gwt-archetype/pom.xml | 2 +- gerrit-plugin-gwtui/pom.xml | 2 +- gerrit-plugin-js-archetype/pom.xml | 2 +- gerrit-war/pom.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Documentation/dev-plugins.txt b/Documentation/dev-plugins.txt index 9a25738ffc..2922a4e8fe 100644 --- a/Documentation/dev-plugins.txt +++ b/Documentation/dev-plugins.txt @@ -36,7 +36,7 @@ plugin project. ---- mvn archetype:generate -DarchetypeGroupId=com.google.gerrit \ -DarchetypeArtifactId=gerrit-plugin-archetype \ - -DarchetypeVersion=2.13.11 \ + -DarchetypeVersion=2.13.12-SNAPSHOT \ -DgroupId=com.googlesource.gerrit.plugins.testplugin \ -DartifactId=testplugin ---- diff --git a/gerrit-acceptance-framework/pom.xml b/gerrit-acceptance-framework/pom.xml index 79e1b23c88..ad17e69f73 100644 --- a/gerrit-acceptance-framework/pom.xml +++ b/gerrit-acceptance-framework/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.google.gerrit gerrit-acceptance-framework - 2.13.11 + 2.13.12-SNAPSHOT jar Gerrit Code Review - Acceptance Test Framework Framework for Gerrit's acceptance tests diff --git a/gerrit-extension-api/pom.xml b/gerrit-extension-api/pom.xml index 30ecca431d..ff86f9effd 100644 --- a/gerrit-extension-api/pom.xml +++ b/gerrit-extension-api/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.google.gerrit gerrit-extension-api - 2.13.11 + 2.13.12-SNAPSHOT jar Gerrit Code Review - Extension API API for Gerrit Extensions diff --git a/gerrit-plugin-api/pom.xml b/gerrit-plugin-api/pom.xml index abd709f766..c77f2c1667 100644 --- a/gerrit-plugin-api/pom.xml +++ b/gerrit-plugin-api/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.google.gerrit gerrit-plugin-api - 2.13.11 + 2.13.12-SNAPSHOT jar Gerrit Code Review - Plugin API API for Gerrit Plugins diff --git a/gerrit-plugin-archetype/pom.xml b/gerrit-plugin-archetype/pom.xml index 0ce1b4da01..1ab3fa4d99 100644 --- a/gerrit-plugin-archetype/pom.xml +++ b/gerrit-plugin-archetype/pom.xml @@ -20,7 +20,7 @@ limitations under the License. com.google.gerrit gerrit-plugin-archetype - 2.13.11 + 2.13.12-SNAPSHOT Gerrit Code Review - Plugin Archetype Maven Archetype for Gerrit Plugins https://www.gerritcodereview.com/ diff --git a/gerrit-plugin-gwt-archetype/pom.xml b/gerrit-plugin-gwt-archetype/pom.xml index 393128cd67..005e8a33fb 100644 --- a/gerrit-plugin-gwt-archetype/pom.xml +++ b/gerrit-plugin-gwt-archetype/pom.xml @@ -20,7 +20,7 @@ limitations under the License. com.google.gerrit gerrit-plugin-gwt-archetype - 2.13.11 + 2.13.12-SNAPSHOT Gerrit Code Review - Web UI GWT Plugin Archetype Maven Archetype for Gerrit Web UI GWT Plugins https://www.gerritcodereview.com/ diff --git a/gerrit-plugin-gwtui/pom.xml b/gerrit-plugin-gwtui/pom.xml index 1278c97077..39a6eb6a3e 100644 --- a/gerrit-plugin-gwtui/pom.xml +++ b/gerrit-plugin-gwtui/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.google.gerrit gerrit-plugin-gwtui - 2.13.11 + 2.13.12-SNAPSHOT jar Gerrit Code Review - Plugin GWT UI Common Classes for Gerrit GWT UI Plugins diff --git a/gerrit-plugin-js-archetype/pom.xml b/gerrit-plugin-js-archetype/pom.xml index 0540c84ad8..3613e06972 100644 --- a/gerrit-plugin-js-archetype/pom.xml +++ b/gerrit-plugin-js-archetype/pom.xml @@ -20,7 +20,7 @@ limitations under the License. com.google.gerrit gerrit-plugin-js-archetype - 2.13.11 + 2.13.12-SNAPSHOT Gerrit Code Review - Web UI JavaScript Plugin Archetype Maven Archetype for Gerrit Web UI JavaScript Plugins https://www.gerritcodereview.com/ diff --git a/gerrit-war/pom.xml b/gerrit-war/pom.xml index 16c9e165cd..3b57ef70c9 100644 --- a/gerrit-war/pom.xml +++ b/gerrit-war/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.google.gerrit gerrit-war - 2.13.11 + 2.13.12-SNAPSHOT war Gerrit Code Review - WAR Gerrit WAR From fa779ef35f022336a74fd10fc7d0cbfe9c38afcb Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Sat, 27 Jan 2018 16:11:21 +0100 Subject: [PATCH 9/9] setup_gjf.sh: Add support for multiple version We are in process of upgrading to new google-java-format version. To simplify upgrade process, allow to set up multiple different versions of gjf distribution. To install currently used version 1.3 no parameter is needed $ tools/setup-gjf.sh The resulting script has now version suffix: tools/format/google-java-format-1.3 To update to a newer version, version parameter can be passed now: $ tools/setup-gjf.sh 1.5 Note, that because of SHA1 check only supported versions can be currently installed: 1.3 and 1.5. Change-Id: Id2464cd88291f7f7376df98ca2a396e2458d07a4 --- tools/setup_gjf.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/setup_gjf.sh b/tools/setup_gjf.sh index 0cf2f3f726..b3ac143744 100755 --- a/tools/setup_gjf.sh +++ b/tools/setup_gjf.sh @@ -17,8 +17,20 @@ set -eu # Keep this version in sync with dev-contributing.txt. -VERSION="1.3" -SHA1="a73cfe6f9af01bd6ff150c0b50c9d620400f784c" +VERSION=${1:-1.3} + +case "$VERSION" in +1.3) + SHA1="a73cfe6f9af01bd6ff150c0b50c9d620400f784c" + ;; +1.5) + SHA1="b1f79e4d39a3c501f07c0ce7e8b03ac6964ed1f1" + ;; +*) + echo "unknown google-java-format version: $VERSION" + exit 1 + ;; +esac root="$(git rev-parse --show-toplevel)" if [[ -z "$root" ]]; then @@ -33,7 +45,7 @@ name="google-java-format-$VERSION-all-deps.jar" url="https://github.com/google/google-java-format/releases/download/google-java-format-$VERSION/$name" "$root/tools/download_file.py" -o "$dir/$name" -u "$url" -v "$SHA1" -launcher="$dir/google-java-format" +launcher="$dir/google-java-format-$VERSION" cat > "$launcher" <