Merge branch 'stable-2.15' into stable-2.16

* stable-2.15:
  Consume JGit artifacts from Maven Central
  Consume JGit artifacts from Maven Central
  gr-related-changes: Don't show "Same topic" for only one change
  RelatedChanges: Don't show "Same Topic" for only one change
  ChangeEditApi: Allow to set options on change edit detail request
  Add Javadoc to clarify behavior of {Accounts|Changes|Groups}#withOptions
  OnlineNoteDbMigrationIT: improve readability of some tests
  Update git submodules
  Add release notes for Gerrit v2.10.8
  Add release notes for Gerrit v2.9.5
  Set version to 2.13.12
  Set version to 2.12.9
  Set version to 2.11.12
  Set version to 2.10.8
  Set version to 2.9.5

Change-Id: Id02a8afc6e4e8d42b759ed2ea28a0926411ff2e8
This commit is contained in:
David Pursehouse
2019-01-18 21:47:17 +09:00
15 changed files with 285 additions and 75 deletions

View File

@@ -172,16 +172,19 @@ public interface Accounts {
return this;
}
/** Set an option on the request, appending to existing options. */
public QueryRequest withOption(ListAccountsOption options) {
this.options.add(options);
return this;
}
/** Set options on the request, appending to existing options. */
public QueryRequest withOptions(ListAccountsOption... options) {
this.options.addAll(Arrays.asList(options));
return this;
}
/** Set options on the request, replacing existing options. */
public QueryRequest withOptions(EnumSet<ListAccountsOption> options) {
this.options = options;
return this;

View File

@@ -14,11 +14,13 @@
package com.google.gerrit.extensions.api.changes;
import com.google.gerrit.extensions.client.ChangeEditDetailOption;
import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.restapi.BinaryResult;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RawInput;
import com.google.gerrit.extensions.restapi.RestApiException;
import java.util.EnumSet;
import java.util.Optional;
/**
@@ -29,6 +31,33 @@ import java.util.Optional;
*/
public interface ChangeEditApi {
abstract class ChangeEditDetailRequest {
private String base;
private EnumSet<ChangeEditDetailOption> options = EnumSet.noneOf(ChangeEditDetailOption.class);
public abstract Optional<EditInfo> get() throws RestApiException;
public ChangeEditDetailRequest withBase(String base) {
this.base = base;
return this;
}
public ChangeEditDetailRequest withOption(ChangeEditDetailOption option) {
this.options.add(option);
return this;
}
public String getBase() {
return base;
}
public EnumSet<ChangeEditDetailOption> options() {
return options;
}
}
ChangeEditDetailRequest detail() throws RestApiException;
/**
* Retrieves details regarding the change edit.
*
@@ -155,6 +184,11 @@ public interface ChangeEditApi {
* interface.
*/
class NotImplemented implements ChangeEditApi {
@Override
public ChangeEditDetailRequest detail() throws RestApiException {
throw new NotImplementedException();
}
@Override
public Optional<EditInfo> get() throws RestApiException {
throw new NotImplementedException();

View File

@@ -94,16 +94,19 @@ public interface Changes {
return this;
}
/** Set an option on the request, appending to existing options. */
public QueryRequest withOption(ListChangesOption options) {
this.options.add(options);
return this;
}
/** Set options on the request, appending to existing options. */
public QueryRequest withOptions(ListChangesOption... options) {
this.options.addAll(Arrays.asList(options));
return this;
}
/** Set options on the request, replacing existing options. */
public QueryRequest withOptions(EnumSet<ListChangesOption> options) {
this.options = options;
return this;

View File

@@ -253,16 +253,19 @@ public interface Groups {
return this;
}
/** Set an option on the request, appending to existing options. */
public QueryRequest withOption(ListGroupsOption options) {
this.options.add(options);
return this;
}
/** Set options on the request, appending to existing options. */
public QueryRequest withOptions(ListGroupsOption... options) {
this.options.addAll(Arrays.asList(options));
return this;
}
/** Set options on the request, replacing existing options. */
public QueryRequest withOptions(EnumSet<ListGroupsOption> options) {
this.options = options;
return this;

View File

@@ -0,0 +1,20 @@
// Copyright (C) 2019 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.extensions.client;
public enum ChangeEditDetailOption {
LIST_FILES,
DOWNLOAD_COMMANDS
}

View File

@@ -18,6 +18,7 @@ import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
import com.google.gerrit.extensions.api.changes.ChangeEditApi;
import com.google.gerrit.extensions.api.changes.PublishChangeEditInput;
import com.google.gerrit.extensions.client.ChangeEditDetailOption;
import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.restapi.AuthException;
@@ -86,6 +87,34 @@ public class ChangeEditApiImpl implements ChangeEditApi {
this.changeResource = changeResource;
}
@Override
public ChangeEditDetailRequest detail() throws RestApiException {
try {
return new ChangeEditDetailRequest() {
@Override
public Optional<EditInfo> get() throws RestApiException {
return ChangeEditApiImpl.this.get(this);
}
};
} catch (Exception e) {
throw asRestApiException("Cannot retrieve change edit", e);
}
}
private Optional<EditInfo> get(ChangeEditDetailRequest r) throws RestApiException {
try {
ChangeEdits.Detail editDetail = editDetailProvider.get();
editDetail.setBase(r.getBase());
editDetail.setList(r.options().contains(ChangeEditDetailOption.LIST_FILES));
editDetail.setDownloadCommands(
r.options().contains(ChangeEditDetailOption.DOWNLOAD_COMMANDS));
Response<EditInfo> edit = editDetail.apply(changeResource);
return edit.isNone() ? Optional.empty() : Optional.of(edit.value());
} catch (Exception e) {
throw asRestApiException("Cannot retrieve change edit", e);
}
}
@Override
public Optional<EditInfo> get() throws RestApiException {
try {

View File

@@ -151,14 +151,24 @@ public class ChangeEdits implements ChildCollection<ChangeResource, ChangeEditRe
private final FileInfoJson fileInfoJson;
private final Revisions revisions;
private String base;
private boolean list;
private boolean downloadCommands;
@Option(name = "--base", metaVar = "revision-id")
String base;
public void setBase(String base) {
this.base = base;
}
@Option(name = "--list")
boolean list;
public void setList(boolean list) {
this.list = list;
}
@Option(name = "--download-commands")
boolean downloadCommands;
public void setDownloadCommands(boolean downloadCommands) {
this.downloadCommands = downloadCommands;
}
@Inject
Detail(