Merge branch 'stable-2.15' into stable-2.16

* stable-2.15:
  Expose Gerrit's GWT client library in the plugin API
  Replace usage of Iterables.limit with Java 8 Stream API
  Follow up to "Adapt gerrit.sh script to work on Alpine Linux"

Change-Id: If66c0dd7f912e4551a6855c3cf299ed2586873dc
This commit is contained in:
David Pursehouse 2019-07-13 10:30:36 +09:00
commit 7b856b1834
6 changed files with 27 additions and 16 deletions

View File

@ -6,6 +6,7 @@ load(
) )
load("//tools/bzl:junit.bzl", "junit_tests") load("//tools/bzl:junit.bzl", "junit_tests")
load("//tools/bzl:license.bzl", "license_test") load("//tools/bzl:license.bzl", "license_test")
load("//tools/bzl:java.bzl", "java_library2")
gwt_genrule() gwt_genrule()
@ -20,6 +21,19 @@ gen_ui_module(
gwt_user_agent_permutations() gwt_user_agent_permutations()
java_library2(
name = "client-lib",
srcs = glob(["src/main/**/*.java"]),
exported_deps = [":ui_module"],
resources = glob(["src/main/**/*"]),
visibility = ["//visibility:public"],
deps = [
"//gerrit-gwtui-common:client-lib",
"//lib/gwt:dev",
"//lib/gwt:user",
],
)
license_test( license_test(
name = "ui_module_license_test", name = "ui_module_license_test",
target = ":ui_module", target = ":ui_module",

View File

@ -19,7 +19,10 @@ java_binary(
java_library2( java_library2(
name = "gwtui-api-lib", name = "gwtui-api-lib",
srcs = SRCS, srcs = SRCS,
exported_deps = ["//gerrit-gwtui-common:client-lib"], exported_deps = [
"//gerrit-gwtui:client-lib",
"//gerrit-gwtui-common:client-lib",
],
resources = glob(["src/main/**/*"]), resources = glob(["src/main/**/*"]),
deps = DEPS + [ deps = DEPS + [
"//java/org/eclipse/jgit:libclient-src.jar", "//java/org/eclipse/jgit:libclient-src.jar",

View File

@ -22,8 +22,6 @@ import static java.util.stream.Collectors.toSet;
import com.google.common.annotations.VisibleForTesting; import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Enums; import com.google.common.base.Enums;
import com.google.common.base.Splitter; import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.common.data.GroupDescription;
@ -1289,7 +1287,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
int maxTerms = args.indexConfig.maxTerms(); int maxTerms = args.indexConfig.maxTerms();
if (allMembers.size() > maxTerms) { if (allMembers.size() > maxTerms) {
// limit the number of query terms otherwise Gerrit will barf // limit the number of query terms otherwise Gerrit will barf
accounts = ImmutableSet.copyOf(Iterables.limit(allMembers, maxTerms)); accounts = allMembers.stream().limit(maxTerms).collect(toSet());
} else { } else {
accounts = allMembers; accounts = allMembers;
} }

View File

@ -20,8 +20,6 @@ import static java.util.stream.Collectors.toList;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.gerrit.common.Nullable; import com.google.gerrit.common.Nullable;
@ -358,10 +356,9 @@ public class ReviewersUtil {
private List<GroupReference> suggestAccountGroups( private List<GroupReference> suggestAccountGroups(
SuggestReviewers suggestReviewers, ProjectState projectState) { SuggestReviewers suggestReviewers, ProjectState projectState) {
return Lists.newArrayList( return groupBackend.suggest(suggestReviewers.getQuery(), projectState).stream()
Iterables.limit( .limit(suggestReviewers.getLimit())
groupBackend.suggest(suggestReviewers.getQuery(), projectState), .collect(toList());
suggestReviewers.getLimit()));
} }
private static class GroupAsReviewer { private static class GroupAsReviewer {

View File

@ -15,10 +15,10 @@
package com.google.gerrit.server.restapi.group; package com.google.gerrit.server.restapi.group;
import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableList.toImmutableList;
import static java.util.stream.Collectors.toList;
import com.google.common.base.MoreObjects; import com.google.common.base.MoreObjects;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Streams; import com.google.common.collect.Streams;
import com.google.gerrit.common.data.GroupDescription; import com.google.gerrit.common.data.GroupDescription;
@ -323,10 +323,9 @@ public class ListGroups implements RestReadView<TopLevelResource> {
"You should only have no more than one --project and -n with --suggest"); "You should only have no more than one --project and -n with --suggest");
} }
List<GroupReference> groupRefs = List<GroupReference> groupRefs =
Lists.newArrayList( groupBackend.suggest(suggest, projects.stream().findFirst().orElse(null)).stream()
Iterables.limit( .limit(limit <= 0 ? 10 : Math.min(limit, 10))
groupBackend.suggest(suggest, projects.stream().findFirst().orElse(null)), .collect(toList());
limit <= 0 ? 10 : Math.min(limit, 10)));
List<GroupInfo> groupInfos = Lists.newArrayListWithCapacity(groupRefs.size()); List<GroupInfo> groupInfos = Lists.newArrayListWithCapacity(groupRefs.size());
for (GroupReference ref : groupRefs) { for (GroupReference ref : groupRefs) {

View File

@ -63,7 +63,7 @@ test $# -gt 0 || usage
running() { running() {
test -f $1 || return 1 test -f $1 || return 1
PID=`cat $1` PID=`cat $1`
ps -o pid | grep -w $PID >/dev/null 2>/dev/null || return 1 ps ax -o pid | grep -w $PID >/dev/null 2>/dev/null || return 1
return 0 return 0
} }