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.
|
# and httpasyncclient as necessary.
|
||||||
maven_jar(
|
maven_jar(
|
||||||
name = "elasticsearch-rest-client",
|
name = "elasticsearch-rest-client",
|
||||||
artifact = "org.elasticsearch.client:elasticsearch-rest-client:6.5.3",
|
artifact = "org.elasticsearch.client:elasticsearch-rest-client:6.5.4",
|
||||||
sha1 = "ac8df46fce1c01b61cbf1f84186bf910d12b577e",
|
sha1 = "552175b06e34df96f114d1c8aaa908e535c8f1be",
|
||||||
)
|
)
|
||||||
|
|
||||||
JACKSON_VERSION = "2.9.8"
|
JACKSON_VERSION = "2.9.8"
|
||||||
|
@@ -105,9 +105,13 @@ public interface ChangeApi {
|
|||||||
|
|
||||||
void setPrivate(boolean value, @Nullable String message) throws RestApiException;
|
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 {
|
default void setWorkInProgress() throws RestApiException {
|
||||||
setWorkInProgress(null);
|
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.ChangeApi;
|
||||||
import com.google.gerrit.extensions.api.changes.CherryPickInput;
|
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.NotImplementedException;
|
||||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||||
|
|
||||||
@@ -23,11 +24,18 @@ public interface CommitApi {
|
|||||||
|
|
||||||
ChangeApi cherryPick(CherryPickInput input) throws RestApiException;
|
ChangeApi cherryPick(CherryPickInput input) throws RestApiException;
|
||||||
|
|
||||||
|
IncludedInInfo includedIn() throws RestApiException;
|
||||||
|
|
||||||
/** A default implementation for source compatibility when adding new methods to the interface. */
|
/** A default implementation for source compatibility when adding new methods to the interface. */
|
||||||
class NotImplemented implements CommitApi {
|
class NotImplemented implements CommitApi {
|
||||||
@Override
|
@Override
|
||||||
public ChangeApi cherryPick(CherryPickInput input) throws RestApiException {
|
public ChangeApi cherryPick(CherryPickInput input) throws RestApiException {
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IncludedInInfo includedIn() throws RestApiException {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -314,7 +314,7 @@ class ChangeApiImpl implements ChangeApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setWorkInProgress(String message) throws RestApiException {
|
public void setWorkInProgress(@Nullable String message) throws RestApiException {
|
||||||
try {
|
try {
|
||||||
setWip.apply(change, new WorkInProgressOp.Input(message));
|
setWip.apply(change, new WorkInProgressOp.Input(message));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -323,7 +323,7 @@ class ChangeApiImpl implements ChangeApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setReadyForReview(String message) throws RestApiException {
|
public void setReadyForReview(@Nullable String message) throws RestApiException {
|
||||||
try {
|
try {
|
||||||
setReady.apply(change, new WorkInProgressOp.Input(message));
|
setReady.apply(change, new WorkInProgressOp.Input(message));
|
||||||
} catch (Exception e) {
|
} 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.ChangeApi;
|
||||||
import com.google.gerrit.extensions.api.changes.Changes;
|
import com.google.gerrit.extensions.api.changes.Changes;
|
||||||
import com.google.gerrit.extensions.api.changes.CherryPickInput;
|
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.api.projects.CommitApi;
|
||||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||||
import com.google.gerrit.server.project.CommitResource;
|
import com.google.gerrit.server.project.CommitResource;
|
||||||
import com.google.gerrit.server.restapi.change.CherryPickCommit;
|
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.Inject;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
|
|
||||||
@@ -33,13 +35,18 @@ public class CommitApiImpl implements CommitApi {
|
|||||||
|
|
||||||
private final Changes changes;
|
private final Changes changes;
|
||||||
private final CherryPickCommit cherryPickCommit;
|
private final CherryPickCommit cherryPickCommit;
|
||||||
|
private final CommitIncludedIn includedIn;
|
||||||
private final CommitResource commitResource;
|
private final CommitResource commitResource;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
CommitApiImpl(
|
CommitApiImpl(
|
||||||
Changes changes, CherryPickCommit cherryPickCommit, @Assisted CommitResource commitResource) {
|
Changes changes,
|
||||||
|
CherryPickCommit cherryPickCommit,
|
||||||
|
CommitIncludedIn includedIn,
|
||||||
|
@Assisted CommitResource commitResource) {
|
||||||
this.changes = changes;
|
this.changes = changes;
|
||||||
this.cherryPickCommit = cherryPickCommit;
|
this.cherryPickCommit = cherryPickCommit;
|
||||||
|
this.includedIn = includedIn;
|
||||||
this.commitResource = commitResource;
|
this.commitResource = commitResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,4 +58,13 @@ public class CommitApiImpl implements CommitApi {
|
|||||||
throw asRestApiException("Cannot cherry pick", e);
|
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;
|
package com.google.gerrit.server.notedb;
|
||||||
|
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
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 static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
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.CommitBuilder;
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
import org.eclipse.jgit.lib.ObjectInserter;
|
import org.eclipse.jgit.lib.ObjectInserter;
|
||||||
|
import org.eclipse.jgit.lib.ObjectLoader;
|
||||||
import org.eclipse.jgit.lib.ObjectReader;
|
import org.eclipse.jgit.lib.ObjectReader;
|
||||||
import org.eclipse.jgit.lib.Ref;
|
import org.eclipse.jgit.lib.Ref;
|
||||||
import org.eclipse.jgit.lib.Repository;
|
import org.eclipse.jgit.lib.Repository;
|
||||||
@@ -222,7 +222,11 @@ public class CommentJsonMigrator {
|
|||||||
NoteMap noteMap = NoteMap.read(reader, c);
|
NoteMap noteMap = NoteMap.read(reader, c);
|
||||||
for (Note note : noteMap) {
|
for (Note note : noteMap) {
|
||||||
// Match pre-parsing logic in RevisionNote#parse().
|
// 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();
|
MutableInteger p = new MutableInteger();
|
||||||
RevisionNote.trimLeadingEmptyLines(raw, p);
|
RevisionNote.trimLeadingEmptyLines(raw, p);
|
||||||
if (!ChangeRevisionNote.isJson(raw, p.value)) {
|
if (!ChangeRevisionNote.isJson(raw, p.value)) {
|
||||||
|
@@ -12,14 +12,14 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// 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 com.google.common.truth.Truth.assertThat;
|
||||||
import static org.eclipse.jgit.lib.Constants.R_TAGS;
|
import static org.eclipse.jgit.lib.Constants.R_TAGS;
|
||||||
|
|
||||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||||
|
import com.google.gerrit.acceptance.NoHttpd;
|
||||||
import com.google.gerrit.acceptance.PushOneCommit.Result;
|
import com.google.gerrit.acceptance.PushOneCommit.Result;
|
||||||
import com.google.gerrit.acceptance.RestResponse;
|
|
||||||
import com.google.gerrit.common.data.Permission;
|
import com.google.gerrit.common.data.Permission;
|
||||||
import com.google.gerrit.extensions.api.changes.IncludedInInfo;
|
import com.google.gerrit.extensions.api.changes.IncludedInInfo;
|
||||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
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.eclipse.jgit.lib.ObjectId;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
@NoHttpd
|
||||||
public class CommitIncludedInIT extends AbstractDaemonTest {
|
public class CommitIncludedInIT extends AbstractDaemonTest {
|
||||||
@Test
|
@Test
|
||||||
public void includedInOpenChange() throws Exception {
|
public void includedInOpenChange() throws Exception {
|
||||||
@@ -60,10 +61,6 @@ public class CommitIncludedInIT extends AbstractDaemonTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private IncludedInInfo getIncludedIn(ObjectId id) throws Exception {
|
private IncludedInInfo getIncludedIn(ObjectId id) throws Exception {
|
||||||
RestResponse r =
|
return gApi.projects().name(project.get()).commit(id.name()).includedIn();
|
||||||
userRestSession.get("/projects/" + project.get() + "/commits/" + id.name() + "/in");
|
|
||||||
IncludedInInfo result = newGson().fromJson(r.getReader(), IncludedInInfo.class);
|
|
||||||
r.consume();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -45,7 +45,7 @@ public class ElasticContainer extends ElasticsearchContainer {
|
|||||||
case V6_4:
|
case V6_4:
|
||||||
return "docker.elastic.co/elasticsearch/elasticsearch-oss:6.4.3";
|
return "docker.elastic.co/elasticsearch/elasticsearch-oss:6.4.3";
|
||||||
case V6_5:
|
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:
|
case V7_0:
|
||||||
return "docker.elastic.co/elasticsearch/elasticsearch-oss:7.0.0-alpha1";
|
return "docker.elastic.co/elasticsearch/elasticsearch-oss:7.0.0-alpha1";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user