Skip to content

Commit

Permalink
Merge branch 'stable-2.15'
Browse files Browse the repository at this point in the history
* stable-2.15:
  Polygerrit: Always create new changes as WIP
  ElasticIndexIT: replace member with local variable
  Elasticsearch tests: remove password duplication
  Fix call to the fail skylark global in junit.bzl
  Set version to 2.14.11-SNAPSHOT
  Set version to 2.14.10
  AbstractQueryChangesTest: Add byMessageSubstring test
  AbstractQueryChangesTest: Expand byTopic with more 'intopic' tests
  Elasticsearch: Add char analyzer to ensure consistency of query results
  Elasticsearch: remove overridden build assignment
  Elasticsearch: run no other test at the same time
  ElasticVersionTest: run it through bazel as well
  Elasticsearch: cover V5 and flaky V6 tests -for CI
  Split Elasticsearch query tests into separate rules
  dev-contributing: Document that we format .bzl files with buildifier
  Add account setting for defaulting new changes to WIP
  Add project setting for defaulting new changes to WIP
  Apply buildifier to .bzl files.
  Update Bower to 1.8.2
  Bump commons-io version to 2.2
  Add missing elasticsearch dependency in pgm tests
  Highlight.js: style gr-syntax-name as gr-syntax-keyword
  Elasticsearch: remove unnecessary test build deps
  Clarify behavior of "Ignore" feature in REST API documentation
  Expose commons-compress in plugin API
  Bump commons-io version to 2.2

Change-Id: I99edb118d193ebe9150f89a902a1407e69711cfc
  • Loading branch information
dpursehouse committed Jul 17, 2018
2 parents 2971c42 + 0f9cd50 commit 4610fca
Show file tree
Hide file tree
Showing 48 changed files with 554 additions and 32 deletions.
13 changes: 13 additions & 0 deletions Documentation/config-project-config.txt
Expand Up @@ -217,6 +217,19 @@ the Git push.
Default is `INHERIT`, which means that this property is inherited from
the parent project.

[[change.workInProgressByDefault]]change.workInProgressByDefault::
+
Controls whether all new changes in the project are set as WIP by default.
+
Note that a new change will be ready if the `workInProgress` field in
link:rest-api-changes.html#change-input[ChangeInput] is set to `false` explicitly
when calling the link:rest-api-changes.html#create-change[CreateChange] REST API
or the `ready` link:user-upload.html#wip[PushOption] is used during
the Git push.
+
Default is `INHERIT`, which means that this property is inherited from
the parent project.

[[submit-section]]
=== Submit section

Expand Down
2 changes: 1 addition & 1 deletion Documentation/dev-contributing.txt
Expand Up @@ -164,7 +164,7 @@ Guide].

To format Java source code, Gerrit uses the
link:https://github.com/google/google-java-format[`google-java-format`]
tool (version 1.5), and to format Bazel BUILD and WORKSPACE files the
tool (version 1.5), and to format Bazel BUILD, WORKSPACE and .bzl files the
link:https://github.com/bazelbuild/buildtools/tree/master/buildifier[`buildifier`]
tool (version 0.12.0).
These tools automatically apply format according to the style guides; this
Expand Down
6 changes: 6 additions & 0 deletions Documentation/intro-user.txt
Expand Up @@ -827,6 +827,12 @@ commands that need to be copied frequently, such as the Change-Ids, commit IDs
and download commands. Note that this option is only shown if the Flash plugin
is available and the JavaScript Clipboard API is unavailable.

- [[work-in-progress-by-default]]`Set new changes work-in-progress`:
+
Whether new changes are uploaded as work-in-progress per default. This
preference just sets the default; the behavior can still be overridden using a
link:user-upload.html#wip[push option].

[[my-menu]]
In addition it is possible to customize the menu entries of the `My`
menu. This can be used to make the navigation to frequently used
Expand Down
5 changes: 5 additions & 0 deletions Documentation/rest-api-accounts.txt
Expand Up @@ -1255,6 +1255,7 @@ any account.
"review_category_strategy": "ABBREV",
"mute_common_path_prefixes": true,
"publish_comments_on_push": true,
"work_in_progress_by_default": true,
"default_base_for_merges": "FIRST_PARENT",
"my": [
{
Expand Down Expand Up @@ -1361,6 +1362,7 @@ link:#preferences-info[PreferencesInfo] entity.
"review_category_strategy": "NAME",
"diff_view": "SIDE_BY_SIDE",
"publish_comments_on_push": true,
"work_in_progress_by_default": true,
"mute_common_path_prefixes": true,
"my": [
{
Expand Down Expand Up @@ -2654,6 +2656,9 @@ Allowed values are `AUTO_MERGE` and `FIRST_PARENT`.
|`publish_comments_on_push` |not set if `false`|
Whether to link:user-upload.html#publish-comments[publish draft comments] on
push by default.
|`work_in_progress_by_default` |not set if `false`|
Whether to link:user-upload.html#wip[set work-in-progress] on
push or on create changes online by default.
|============================================

[[preferences-input]]
Expand Down
4 changes: 3 additions & 1 deletion Documentation/rest-api-changes.txt
Expand Up @@ -2277,7 +2277,9 @@ POST request:
--

Marks a change as ignored. The change will not be shown in the incoming
reviews dashboard, and email notifications will be suppressed.
reviews dashboard, and email notifications will be suppressed. Ignoring
a change does not cause the change's "updated" timestamp to be modified,
and the owner is not notified.

.Request
----
Expand Down
7 changes: 5 additions & 2 deletions Documentation/rest-api-projects.txt
Expand Up @@ -2890,10 +2890,13 @@ signed push validation is required on the project.
|`reject_implicit_merges`|optional|
link:#inherited-boolean-info[InheritedBooleanInfo] that tells whether
implicit merges should be rejected on changes pushed to the project.
|`private_by_default` ||
|`private_by_default` ||
link:#inherited-boolean-info[InheritedBooleanInfo] that tells whether
all new changes are set as private by default.
|`max_object_size_limit` ||
|`work_in_progress_by_default`||
link:#inherited-boolean-info[InheritedBooleanInfo] that tells whether
all new changes are set as work-in-progress by default.
|`max_object_size_limit` ||
The link:config-gerrit.html#receive.maxObjectSizeLimit[max object size
limit] of this project as a link:#max-object-size-limit-info[
MaxObjectSizeLimitInfo] entity.
Expand Down
5 changes: 5 additions & 0 deletions Documentation/user-upload.txt
Expand Up @@ -309,6 +309,11 @@ flag from a change on push, explicitly specify the `ready` option:
Only change owners, project owners and site administrators can specify
`work-in-progress` and `ready` options on push.

The default for this option can be set as a
link:intro-user.html#work-in-progress-by-default[user preference]. If the
preference is set so the default behavior is to create `work-in-progress`
changes, this can be overridden with the `ready` option.

[[message]]
==== Message

Expand Down
4 changes: 2 additions & 2 deletions WORKSPACE
Expand Up @@ -878,8 +878,8 @@ maven_jar(

maven_jar(
name = "commons-io",
artifact = "commons-io:commons-io:1.4",
sha1 = "a8762d07e76cfde2395257a5da47ba7c1dbd3dce",
artifact = "commons-io:commons-io:2.2",
sha1 = "83b5b8a7ba1c08f9e8c8ff2373724e33d3c1e22a",
)

maven_jar(
Expand Down
21 changes: 21 additions & 0 deletions gerrit-acceptance-tests/tests.bzl
@@ -0,0 +1,21 @@
load("//tools/bzl:junit.bzl", "junit_tests")

def acceptance_tests(
group,
deps = [],
labels = [],
vm_args = ["-Xmx256m"],
**kwargs):
junit_tests(
name = group,
deps = deps + [
"//gerrit-acceptance-tests:lib",
],
tags = labels + [
"acceptance",
"slow",
],
size = "large",
jvm_flags = vm_args,
**kwargs
)
Expand Up @@ -151,6 +151,9 @@ public final DefaultBase defaultBaseForMerges() {
public final native boolean
publishCommentsOnPush() /*-{ return this.publish_comments_on_push || false }-*/;

public final native boolean
workInProgressByDefault() /*-{ return this.work_in_progress_by_default || false }-*/;

public final native JsArray<TopMenuItem> my() /*-{ return this.my; }-*/;

public final native void changesPerPage(int n) /*-{ this.changes_per_page = n }-*/;
Expand Down Expand Up @@ -230,6 +233,9 @@ public final void defaultBaseForMerges(DefaultBase b) {
public final native void publishCommentsOnPush(
boolean p) /*-{ this.publish_comments_on_push = p }-*/;

public final native void workInProgressByDefault(
boolean p) /*-{ this.work_in_progress_by_default = p }-*/;

public final void setMyMenus(List<TopMenuItem> myMenus) {
initMy();
for (TopMenuItem n : myMenus) {
Expand Down
Expand Up @@ -69,6 +69,8 @@ public interface AccountConstants extends Constants {

String publishCommentsOnPush();

String workInProgressByDefault();

String myMenu();

String myMenuInfo();
Expand Down
Expand Up @@ -39,6 +39,7 @@ showLegacycidInChangeTable = Show Change Number In Changes Table
muteCommonPathPrefixes = Mute Common Path Prefixes In File List
signedOffBy = Insert Signed-off-by Footer For Inline Edit Changes
publishCommentsOnPush = Publish Comments On Push
workInProgressByDefault = Set all new changes work-in-progress by default
myMenu = My Menu
myMenuInfo = \
Menu items for the 'My' top level menu. \
Expand Down
Expand Up @@ -56,6 +56,7 @@ public class MyPreferencesScreen extends SettingsScreen {
private CheckBox muteCommonPathPrefixes;
private CheckBox signedOffBy;
private CheckBox publishCommentsOnPush;
private CheckBox workInProgressByDefault;
private ListBox maximumPageSize;
private ListBox dateFormat;
private ListBox timeFormat;
Expand Down Expand Up @@ -163,9 +164,10 @@ protected void onInitUI() {
muteCommonPathPrefixes = new CheckBox(Util.C.muteCommonPathPrefixes());
signedOffBy = new CheckBox(Util.C.signedOffBy());
publishCommentsOnPush = new CheckBox(Util.C.publishCommentsOnPush());
workInProgressByDefault = new CheckBox(Util.C.workInProgressByDefault());

boolean flashClippy = !UserAgent.hasJavaScriptClipboard() && UserAgent.Flash.isInstalled();
final Grid formGrid = new Grid(15 + (flashClippy ? 1 : 0), 2);
final Grid formGrid = new Grid(16 + (flashClippy ? 1 : 0), 2);

int row = 0;

Expand Down Expand Up @@ -229,6 +231,10 @@ protected void onInitUI() {
formGrid.setWidget(row, fieldIdx, publishCommentsOnPush);
row++;

formGrid.setText(row, labelIdx, "");
formGrid.setWidget(row, fieldIdx, workInProgressByDefault);
row++;

if (flashClippy) {
formGrid.setText(row, labelIdx, "");
formGrid.setWidget(row, fieldIdx, useFlashClipboard);
Expand Down Expand Up @@ -264,6 +270,7 @@ public void onClick(ClickEvent event) {
e.listenTo(muteCommonPathPrefixes);
e.listenTo(signedOffBy);
e.listenTo(publishCommentsOnPush);
e.listenTo(workInProgressByDefault);
e.listenTo(diffView);
e.listenTo(reviewCategoryStrategy);
e.listenTo(emailStrategy);
Expand Down Expand Up @@ -303,6 +310,7 @@ private void enable(boolean on) {
muteCommonPathPrefixes.setEnabled(on);
signedOffBy.setEnabled(on);
publishCommentsOnPush.setEnabled(on);
workInProgressByDefault.setEnabled(on);
reviewCategoryStrategy.setEnabled(on);
diffView.setEnabled(on);
emailStrategy.setEnabled(on);
Expand All @@ -329,6 +337,7 @@ private void display(GeneralPreferences p) {
muteCommonPathPrefixes.setValue(p.muteCommonPathPrefixes());
signedOffBy.setValue(p.signedOffBy());
publishCommentsOnPush.setValue(p.publishCommentsOnPush());
workInProgressByDefault.setValue(p.workInProgressByDefault());
setListBox(
reviewCategoryStrategy,
GeneralPreferencesInfo.ReviewCategoryStrategy.NONE,
Expand Down Expand Up @@ -421,6 +430,7 @@ private void doSave() {
p.muteCommonPathPrefixes(muteCommonPathPrefixes.getValue());
p.signedOffBy(signedOffBy.getValue());
p.publishCommentsOnPush(publishCommentsOnPush.getValue());
p.workInProgressByDefault(workInProgressByDefault.getValue());
p.reviewCategoryStrategy(
getListBox(
reviewCategoryStrategy, ReviewCategoryStrategy.NONE, ReviewCategoryStrategy.values()));
Expand Down
Expand Up @@ -79,6 +79,8 @@ public interface AdminConstants extends Constants {

String privateByDefault();

String workInProgressByDefault();

String enableReviewerByEmail();

String matchAuthorToCommitterDate();
Expand Down
Expand Up @@ -31,6 +31,7 @@ requireSignedPush = Require signed push
requireChangeID = Require <code>Change-Id</code> in commit message
rejectImplicitMerges = Reject implicit merges when changes are pushed for review
privateByDefault = Set all new changes private by default
workInProgressByDefault = Set all new changes work-in-progress by default
headingMaxObjectSizeLimit = Maximum Git object size limit
headingGroupOptions = Group Options
isVisibleToAll = Make group visible to all registered users.
Expand Down
Expand Up @@ -88,6 +88,7 @@ public class ProjectInfoScreen extends ProjectScreen {
private ListBox requireSignedPush;
private ListBox rejectImplicitMerges;
private ListBox privateByDefault;
private ListBox workInProgressByDefault;
private ListBox enableReviewerByEmail;
private ListBox matchAuthorToCommitterDate;
private NpTextBox maxObjectSizeLimit;
Expand Down Expand Up @@ -198,6 +199,7 @@ private void enableForm(boolean isOwner) {
requireChangeID.setEnabled(isOwner);
rejectImplicitMerges.setEnabled(isOwner);
privateByDefault.setEnabled(isOwner);
workInProgressByDefault.setEnabled(isOwner);
maxObjectSizeLimit.setEnabled(isOwner);
enableReviewerByEmail.setEnabled(isOwner);
matchAuthorToCommitterDate.setEnabled(isOwner);
Expand Down Expand Up @@ -278,6 +280,10 @@ public void onChange(ChangeEvent event) {
saveEnabler.listenTo(privateByDefault);
grid.addHtml(AdminConstants.I.privateByDefault(), privateByDefault);

workInProgressByDefault = newInheritedBooleanBox();
saveEnabler.listenTo(workInProgressByDefault);
grid.addHtml(AdminConstants.I.workInProgressByDefault(), workInProgressByDefault);

enableReviewerByEmail = newInheritedBooleanBox();
saveEnabler.listenTo(enableReviewerByEmail);
grid.addHtml(AdminConstants.I.enableReviewerByEmail(), enableReviewerByEmail);
Expand Down Expand Up @@ -427,6 +433,7 @@ void display(ConfigInfo result) {
}
setBool(rejectImplicitMerges, result.rejectImplicitMerges());
setBool(privateByDefault, result.privateByDefault());
setBool(workInProgressByDefault, result.workInProgressByDefault());
setBool(enableReviewerByEmail, result.enableReviewerByEmail());
setBool(matchAuthorToCommitterDate, result.matchAuthorToCommitterDate());
setSubmitType(result.defaultSubmitType());
Expand Down Expand Up @@ -700,6 +707,7 @@ private void doSave() {
rsp,
getBool(rejectImplicitMerges),
getBool(privateByDefault),
getBool(workInProgressByDefault),
getBool(enableReviewerByEmail),
getBool(matchAuthorToCommitterDate),
maxObjectSizeLimit.getText().trim(),
Expand Down
Expand Up @@ -60,6 +60,9 @@ public final native InheritedBooleanInfo rejectImplicitMerges()
public final native InheritedBooleanInfo privateByDefault()
/*-{ return this.private_by_default; }-*/ ;

public final native InheritedBooleanInfo workInProgressByDefault()
/*-{ return this.work_in_progress_by_default; }-*/ ;

public final native InheritedBooleanInfo enableReviewerByEmail()
/*-{ return this.enable_reviewer_by_email; }-*/ ;

Expand Down
Expand Up @@ -153,6 +153,7 @@ public static void setConfig(
InheritableBoolean requireSignedPush,
InheritableBoolean rejectImplicitMerges,
InheritableBoolean privateByDefault,
InheritableBoolean workInProgressByDefault,
InheritableBoolean enableReviewerByEmail,
InheritableBoolean matchAuthorToCommitterDate,
String maxObjectSizeLimit,
Expand All @@ -175,6 +176,7 @@ public static void setConfig(
}
in.setRejectImplicitMerges(rejectImplicitMerges);
in.setPrivateByDefault(privateByDefault);
in.setWorkInProgressByDefault(workInProgressByDefault);
in.setMaxObjectSizeLimit(maxObjectSizeLimit);
if (submitType != null) {
in.setSubmitType(submitType);
Expand Down Expand Up @@ -313,6 +315,13 @@ final void setPrivateByDefault(InheritableBoolean v) {

private native void setPrivateByDefault(String v) /*-{ if(v)this.private_by_default=v; }-*/;

final void setWorkInProgressByDefault(InheritableBoolean v) {
setWorkInProgressByDefault(v.name());
}

private native void setWorkInProgressByDefault(
String v) /*-{ if(v)this.work_in_progress_by_default=v; }-*/;

final void setEnableReviewerByEmail(InheritableBoolean v) {
setEnableReviewerByEmailRaw(v.name());
}
Expand Down
13 changes: 12 additions & 1 deletion java/com/google/gerrit/elasticsearch/AbstractElasticIndex.java
Expand Up @@ -21,6 +21,7 @@

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Lists;
import com.google.common.flogger.FluentLogger;
Expand Down Expand Up @@ -79,6 +80,7 @@ abstract class AbstractElasticIndex<K, V> implements Index<K, V> {
protected static final String MAPPINGS = "mappings";
protected static final String ORDER = "order";
protected static final String SEARCH = "_search";
protected static final String SETTINGS = "settings";

protected static <T> List<T> decodeProtos(
JsonObject doc, String fieldName, ProtobufCodec<T> codec) {
Expand Down Expand Up @@ -181,7 +183,8 @@ public void deleteAll() throws IOException {
}

// Recreate the index.
response = performRequest("PUT", getMappings(), indexName, Collections.emptyMap());
String indexCreationFields = concatJsonString(getSettings(), getMappings());
response = performRequest("PUT", indexCreationFields, indexName, Collections.emptyMap());
statusCode = response.getStatusLine().getStatusCode();
if (statusCode != HttpStatus.SC_OK) {
String error = String.format("Failed to create index %s: %s", indexName, statusCode);
Expand All @@ -193,6 +196,10 @@ public void deleteAll() throws IOException {

protected abstract String getMappings();

private String getSettings() {
return gson.toJson(ImmutableMap.of(SETTINGS, ElasticSetting.createSetting()));
}

protected abstract String getId(V v);

protected String getMappingsForSingleType(String candidateType, MappingProperties properties) {
Expand Down Expand Up @@ -294,6 +301,10 @@ protected Response postRequest(Object payload, String uri, Map<String, String> p
return performRequest("POST", payload, uri, params);
}

private String concatJsonString(String target, String addition) {
return target.substring(0, target.length() - 1) + "," + addition.substring(1);
}

private Response performRequest(
String method, Object payload, String uri, Map<String, String> params) throws IOException {
String payloadStr = payload instanceof String ? (String) payload : payload.toString();
Expand Down

0 comments on commit 4610fca

Please sign in to comment.