Merge branch 'stable-2.16'
* stable-2.16: CommentJsonMigrator: Improve error handling if comment note is too large ChangeApi: Add default implementation of setPrivate with null message ChangeApi: Annotate nullable message parameters as @Nullable ProjectApi: Add methods to get/set project's HEAD CommitApi: Add method to get "included in" information Upgrade elasticsearch-rest-client to 6.5.4 Add the GWT hash separator to the GWT url Change-Id: I206f68848adf7fad2a0dc3d8b12db28c9e8bf7e5
This commit is contained in:
@@ -1009,8 +1009,8 @@ maven_jar(
|
||||
# and httpasyncclient as necessary.
|
||||
maven_jar(
|
||||
name = "elasticsearch-rest-client",
|
||||
artifact = "org.elasticsearch.client:elasticsearch-rest-client:6.5.3",
|
||||
sha1 = "ac8df46fce1c01b61cbf1f84186bf910d12b577e",
|
||||
artifact = "org.elasticsearch.client:elasticsearch-rest-client:6.5.4",
|
||||
sha1 = "552175b06e34df96f114d1c8aaa908e535c8f1be",
|
||||
)
|
||||
|
||||
JACKSON_VERSION = "2.9.8"
|
||||
|
@@ -105,9 +105,13 @@ public interface ChangeApi {
|
||||
|
||||
void setPrivate(boolean value, @Nullable String message) throws RestApiException;
|
||||
|
||||
void setWorkInProgress(String message) throws RestApiException;
|
||||
default void setPrivate(boolean value) throws RestApiException {
|
||||
setPrivate(value, null);
|
||||
}
|
||||
|
||||
void setReadyForReview(String message) throws RestApiException;
|
||||
void setWorkInProgress(@Nullable String message) throws RestApiException;
|
||||
|
||||
void setReadyForReview(@Nullable String message) throws RestApiException;
|
||||
|
||||
default void setWorkInProgress() throws RestApiException {
|
||||
setWorkInProgress(null);
|
||||
|
@@ -16,6 +16,7 @@ package com.google.gerrit.extensions.api.projects;
|
||||
|
||||
import com.google.gerrit.extensions.api.changes.ChangeApi;
|
||||
import com.google.gerrit.extensions.api.changes.CherryPickInput;
|
||||
import com.google.gerrit.extensions.api.changes.IncludedInInfo;
|
||||
import com.google.gerrit.extensions.restapi.NotImplementedException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
|
||||
@@ -23,11 +24,18 @@ public interface CommitApi {
|
||||
|
||||
ChangeApi cherryPick(CherryPickInput input) throws RestApiException;
|
||||
|
||||
IncludedInInfo includedIn() throws RestApiException;
|
||||
|
||||
/** A default implementation for source compatibility when adding new methods to the interface. */
|
||||
class NotImplemented implements CommitApi {
|
||||
@Override
|
||||
public ChangeApi cherryPick(CherryPickInput input) throws RestApiException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IncludedInInfo includedIn() throws RestApiException {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -314,7 +314,7 @@ class ChangeApiImpl implements ChangeApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWorkInProgress(String message) throws RestApiException {
|
||||
public void setWorkInProgress(@Nullable String message) throws RestApiException {
|
||||
try {
|
||||
setWip.apply(change, new WorkInProgressOp.Input(message));
|
||||
} catch (Exception e) {
|
||||
@@ -323,7 +323,7 @@ class ChangeApiImpl implements ChangeApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadyForReview(String message) throws RestApiException {
|
||||
public void setReadyForReview(@Nullable String message) throws RestApiException {
|
||||
try {
|
||||
setReady.apply(change, new WorkInProgressOp.Input(message));
|
||||
} catch (Exception e) {
|
||||
|
@@ -19,10 +19,12 @@ import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
||||
import com.google.gerrit.extensions.api.changes.ChangeApi;
|
||||
import com.google.gerrit.extensions.api.changes.Changes;
|
||||
import com.google.gerrit.extensions.api.changes.CherryPickInput;
|
||||
import com.google.gerrit.extensions.api.changes.IncludedInInfo;
|
||||
import com.google.gerrit.extensions.api.projects.CommitApi;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.server.project.CommitResource;
|
||||
import com.google.gerrit.server.restapi.change.CherryPickCommit;
|
||||
import com.google.gerrit.server.restapi.project.CommitIncludedIn;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
@@ -33,13 +35,18 @@ public class CommitApiImpl implements CommitApi {
|
||||
|
||||
private final Changes changes;
|
||||
private final CherryPickCommit cherryPickCommit;
|
||||
private final CommitIncludedIn includedIn;
|
||||
private final CommitResource commitResource;
|
||||
|
||||
@Inject
|
||||
CommitApiImpl(
|
||||
Changes changes, CherryPickCommit cherryPickCommit, @Assisted CommitResource commitResource) {
|
||||
Changes changes,
|
||||
CherryPickCommit cherryPickCommit,
|
||||
CommitIncludedIn includedIn,
|
||||
@Assisted CommitResource commitResource) {
|
||||
this.changes = changes;
|
||||
this.cherryPickCommit = cherryPickCommit;
|
||||
this.includedIn = includedIn;
|
||||
this.commitResource = commitResource;
|
||||
}
|
||||
|
||||
@@ -51,4 +58,13 @@ public class CommitApiImpl implements CommitApi {
|
||||
throw asRestApiException("Cannot cherry pick", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IncludedInInfo includedIn() throws RestApiException {
|
||||
try {
|
||||
return includedIn.apply(commitResource);
|
||||
} catch (Exception e) {
|
||||
throw asRestApiException("Could not extract IncludedIn data", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,6 @@
|
||||
package com.google.gerrit.server.notedb;
|
||||
|
||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||
import static com.google.gerrit.server.notedb.RevisionNote.MAX_NOTE_SZ;
|
||||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -40,6 +39,7 @@ import org.eclipse.jgit.lib.BatchRefUpdate;
|
||||
import org.eclipse.jgit.lib.CommitBuilder;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.ObjectInserter;
|
||||
import org.eclipse.jgit.lib.ObjectLoader;
|
||||
import org.eclipse.jgit.lib.ObjectReader;
|
||||
import org.eclipse.jgit.lib.Ref;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
@@ -222,7 +222,11 @@ public class CommentJsonMigrator {
|
||||
NoteMap noteMap = NoteMap.read(reader, c);
|
||||
for (Note note : noteMap) {
|
||||
// Match pre-parsing logic in RevisionNote#parse().
|
||||
byte[] raw = reader.open(note.getData(), OBJ_BLOB).getCachedBytes(MAX_NOTE_SZ);
|
||||
ObjectLoader objectLoader = reader.open(note.getData(), OBJ_BLOB);
|
||||
if (objectLoader.isLarge()) {
|
||||
throw new IOException(String.format("Comment note %s is too large", note.name()));
|
||||
}
|
||||
byte[] raw = objectLoader.getCachedBytes();
|
||||
MutableInteger p = new MutableInteger();
|
||||
RevisionNote.trimLeadingEmptyLines(raw, p);
|
||||
if (!ChangeRevisionNote.isJson(raw, p.value)) {
|
||||
|
@@ -12,14 +12,14 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.acceptance.rest.project;
|
||||
package com.google.gerrit.acceptance.api.project;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.eclipse.jgit.lib.Constants.R_TAGS;
|
||||
|
||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||
import com.google.gerrit.acceptance.NoHttpd;
|
||||
import com.google.gerrit.acceptance.PushOneCommit.Result;
|
||||
import com.google.gerrit.acceptance.RestResponse;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.extensions.api.changes.IncludedInInfo;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
@@ -28,6 +28,7 @@ import com.google.gerrit.reviewdb.client.Branch;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.junit.Test;
|
||||
|
||||
@NoHttpd
|
||||
public class CommitIncludedInIT extends AbstractDaemonTest {
|
||||
@Test
|
||||
public void includedInOpenChange() throws Exception {
|
||||
@@ -60,10 +61,6 @@ public class CommitIncludedInIT extends AbstractDaemonTest {
|
||||
}
|
||||
|
||||
private IncludedInInfo getIncludedIn(ObjectId id) throws Exception {
|
||||
RestResponse r =
|
||||
userRestSession.get("/projects/" + project.get() + "/commits/" + id.name() + "/in");
|
||||
IncludedInInfo result = newGson().fromJson(r.getReader(), IncludedInInfo.class);
|
||||
r.consume();
|
||||
return result;
|
||||
return gApi.projects().name(project.get()).commit(id.name()).includedIn();
|
||||
}
|
||||
}
|
@@ -45,7 +45,7 @@ public class ElasticContainer extends ElasticsearchContainer {
|
||||
case V6_4:
|
||||
return "docker.elastic.co/elasticsearch/elasticsearch-oss:6.4.3";
|
||||
case V6_5:
|
||||
return "docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.3";
|
||||
return "docker.elastic.co/elasticsearch/elasticsearch-oss:6.5.4";
|
||||
case V7_0:
|
||||
return "docker.elastic.co/elasticsearch/elasticsearch-oss:7.0.0-alpha1";
|
||||
}
|
||||
|
Reference in New Issue
Block a user