Merge branch 'stable-2.15' into stable-2.16

* stable-2.15:
  ElasticContainer: Upgrade to 6.8.2 image for V6_8 tests
  Fix typo: program
  Clarify usage of 'parent' option in list files API
  Remove unused Skylark patch file
  Files: Use Gerrit API to get revision parents
  Add support for Elasticsearch version 6.8.x
  Upgrade elasticsearch-rest-client to 7.2.1
  CommitApi: Add method to get commit info
  Consolidate all CommitApi tests into a single class
  Files: Validate parent option to prevent internal server error
  RevisionIT: Assert that files(base) only works for patch set revisions
  Fix and expand documentation of REST API to get revision files
  RevisionIT#files: Simplify assertion
  Update git submodules

Also update ElasticV6QueryProjectsTest to use V6_8.

Change-Id: I98da65486f39acad509529ff90540d9f8ae00a2d
This commit is contained in:
David Pursehouse
2019-08-05 10:13:00 +09:00
19 changed files with 292 additions and 153 deletions

View File

@@ -4893,12 +4893,22 @@ need the FileInfo should make two requests.
The request parameter `q` changes the response to return a list
of all files (modified or unmodified) that contain that substring
in the path name. This is useful to implement suggestion services
finding a file by partial name.
finding a file by partial name. Clients that also need the FileInfo
should make two requests.
The integer-valued request parameter `parent` changes the response to return a
list of the files which are different in this commit compared to the given
parent commit. This is useful for supporting review of merge commits. The value
is the 1-based index of the parent's position in the commit object.
For merge commits only, the integer-valued request parameter `parent`
changes the response to return a map of the files which are different
in this commit compared to the given parent commit. The value is the
1-based index of the parent's position in the commit object. If not
specified, the response contains a map of the files different in the
auto merge result.
The request parameter `base` changes the response to return a map of the
files which are different in this commit compared to the given revision. The
revision must correspond to a patch set in the change.
The `reviewed`, `q`, `parent`, and `base` options are mutually exclusive.
That is, only one of them may be used at a time.
.Request
----

View File

@@ -1116,8 +1116,8 @@ maven_jar(
# and httpasyncclient as necessary.
maven_jar(
name = "elasticsearch-rest-client",
artifact = "org.elasticsearch.client:elasticsearch-rest-client:7.2.0",
sha1 = "39cf34068b0af284eaa9b8bd86a131cb24b322d5",
artifact = "org.elasticsearch.client:elasticsearch-rest-client:7.2.1",
sha1 = "5303a802c02e67683ce30b7e9a23d2e9c523782b",
)
maven_jar(

View File

@@ -25,6 +25,7 @@ public enum ElasticVersion {
V6_5("6.5.*"),
V6_6("6.6.*"),
V6_7("6.7.*"),
V6_8("6.8.*"),
V7_0("7.0.*"),
V7_1("7.1.*"),
V7_2("7.2.*");

View File

@@ -17,10 +17,12 @@ 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.common.CommitInfo;
import com.google.gerrit.extensions.restapi.NotImplementedException;
import com.google.gerrit.extensions.restapi.RestApiException;
public interface CommitApi {
CommitInfo get() throws RestApiException;
ChangeApi cherryPick(CherryPickInput input) throws RestApiException;
@@ -28,6 +30,11 @@ public interface CommitApi {
/** A default implementation for source compatibility when adding new methods to the interface. */
class NotImplemented implements CommitApi {
@Override
public CommitInfo get() throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeApi cherryPick(CherryPickInput input) throws RestApiException {
throw new NotImplementedException();

View File

@@ -66,7 +66,7 @@ public final class GerritLauncher {
}
/**
* Invokes a proram.
* Invokes a program.
*
* <p>Creates a new classloader to load and run the program class. To reuse a classloader across
* calls (e.g. from tests), use {@link #invokeProgram(ClassLoader, String[])}.
@@ -177,7 +177,7 @@ public final class GerritLauncher {
}
/**
* Invokes a proram in the provided {@code ClassLoader}.
* Invokes a program in the provided {@code ClassLoader}.
*
* @param loader classloader to load program class from.
* @param origArgv arguments, as would be passed to {@code gerrit.war}. The first argument is the

View File

@@ -21,10 +21,12 @@ 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.common.CommitInfo;
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.gerrit.server.restapi.project.GetCommit;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
@@ -34,6 +36,7 @@ public class CommitApiImpl implements CommitApi {
}
private final Changes changes;
private final GetCommit getCommit;
private final CherryPickCommit cherryPickCommit;
private final CommitIncludedIn includedIn;
private final CommitResource commitResource;
@@ -41,15 +44,26 @@ public class CommitApiImpl implements CommitApi {
@Inject
CommitApiImpl(
Changes changes,
GetCommit getCommit,
CherryPickCommit cherryPickCommit,
CommitIncludedIn includedIn,
@Assisted CommitResource commitResource) {
this.changes = changes;
this.getCommit = getCommit;
this.cherryPickCommit = cherryPickCommit;
this.includedIn = includedIn;
this.commitResource = commitResource;
}
@Override
public CommitInfo get() throws RestApiException {
try {
return getCommit.apply(commitResource);
} catch (Exception e) {
throw asRestApiException("Cannot get commit info", e);
}
}
@Override
public ChangeApi cherryPick(CherryPickInput input) throws RestApiException {
try {

View File

@@ -18,6 +18,7 @@ import com.google.common.collect.Lists;
import com.google.common.flogger.FluentLogger;
import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing;
import com.google.gerrit.extensions.api.GerritApi;
import com.google.gerrit.extensions.common.FileInfo;
import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.restapi.AuthException;
@@ -26,8 +27,8 @@ import com.google.gerrit.extensions.restapi.CacheControl;
import com.google.gerrit.extensions.restapi.ChildCollection;
import com.google.gerrit.extensions.restapi.ETagView;
import com.google.gerrit.extensions.restapi.IdString;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
import com.google.gerrit.extensions.restapi.Response;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.extensions.restapi.RestView;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
@@ -121,6 +122,7 @@ public class Files implements ChildCollection<RevisionResource, FileResource> {
private final PatchListCache patchListCache;
private final PatchSetUtil psUtil;
private final PluginItemContext<AccountPatchReviewStore> accountPatchReviewStore;
private final GerritApi gApi;
@Inject
ListFiles(
@@ -131,7 +133,8 @@ public class Files implements ChildCollection<RevisionResource, FileResource> {
GitRepositoryManager gitManager,
PatchListCache patchListCache,
PatchSetUtil psUtil,
PluginItemContext<AccountPatchReviewStore> accountPatchReviewStore) {
PluginItemContext<AccountPatchReviewStore> accountPatchReviewStore,
GerritApi gApi) {
this.db = db;
this.self = self;
this.fileInfoJson = fileInfoJson;
@@ -140,6 +143,7 @@ public class Files implements ChildCollection<RevisionResource, FileResource> {
this.patchListCache = patchListCache;
this.psUtil = psUtil;
this.accountPatchReviewStore = accountPatchReviewStore;
this.gApi = gApi;
}
public ListFiles setReviewed(boolean r) {
@@ -149,9 +153,8 @@ public class Files implements ChildCollection<RevisionResource, FileResource> {
@Override
public Response<?> apply(RevisionResource resource)
throws AuthException, BadRequestException, ResourceNotFoundException, OrmException,
RepositoryNotFoundException, IOException, PatchListNotAvailableException,
PermissionBackendException {
throws RestApiException, OrmException, RepositoryNotFoundException, IOException,
PatchListNotAvailableException, PermissionBackendException {
checkOptions();
if (reviewed) {
return Response.ok(reviewed(resource));
@@ -169,7 +172,17 @@ public class Files implements ChildCollection<RevisionResource, FileResource> {
resource.getChange(),
resource.getPatchSet().getRevision(),
baseResource.getPatchSet()));
} else if (parentNum > 0) {
} else if (parentNum != 0) {
int parents =
gApi.changes()
.id(resource.getChange().getChangeId())
.revision(resource.getPatchSet().getId().get())
.commit(false)
.parents
.size();
if (parentNum < 0 || parentNum > parents) {
throw new BadRequestException(String.format("invalid parent number: %d", parentNum));
}
r =
Response.ok(
fileInfoJson.toFileInfoMap(

View File

@@ -0,0 +1,151 @@
// Copyright (C) 2017 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.acceptance.api.project;
import static com.google.common.truth.Truth.assertThat;
import static java.util.stream.Collectors.toList;
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.TestAccount;
import com.google.gerrit.common.data.Permission;
import com.google.gerrit.extensions.api.changes.CherryPickInput;
import com.google.gerrit.extensions.api.changes.IncludedInInfo;
import com.google.gerrit.extensions.api.changes.ReviewInput;
import com.google.gerrit.extensions.api.projects.BranchInput;
import com.google.gerrit.extensions.api.projects.TagInput;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.ChangeMessageInfo;
import com.google.gerrit.extensions.common.CommitInfo;
import com.google.gerrit.extensions.common.GitPerson;
import com.google.gerrit.extensions.common.RevisionInfo;
import com.google.gerrit.reviewdb.client.Branch;
import java.util.Iterator;
import java.util.List;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import org.junit.Test;
@NoHttpd
public class CommitIT extends AbstractDaemonTest {
@Test
public void getCommitInfo() throws Exception {
Result result = createChange();
String commitId = result.getCommit().getId().name();
CommitInfo info = gApi.projects().name(project.get()).commit(commitId).get();
assertThat(info.commit).isEqualTo(commitId);
assertThat(info.parents.stream().map(c -> c.commit).collect(toList()))
.containsExactly(result.getCommit().getParent(0).name());
assertThat(info.subject).isEqualTo(result.getCommit().getShortMessage());
assertPerson(info.author, admin);
assertPerson(info.committer, admin);
assertThat(info.webLinks).isNull();
}
@Test
public void includedInOpenChange() throws Exception {
Result result = createChange();
assertThat(getIncludedIn(result.getCommit().getId()).branches).isEmpty();
assertThat(getIncludedIn(result.getCommit().getId()).tags).isEmpty();
}
@Test
public void includedInMergedChange() throws Exception {
Result result = createChange();
gApi.changes()
.id(result.getChangeId())
.revision(result.getCommit().name())
.review(ReviewInput.approve());
gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).submit();
assertThat(getIncludedIn(result.getCommit().getId()).branches).containsExactly("master");
assertThat(getIncludedIn(result.getCommit().getId()).tags).isEmpty();
grant(project, R_TAGS + "*", Permission.CREATE_TAG);
gApi.projects().name(result.getChange().project().get()).tag("test-tag").create(new TagInput());
assertThat(getIncludedIn(result.getCommit().getId()).tags).containsExactly("test-tag");
createBranch(new Branch.NameKey(project.get(), "test-branch"));
assertThat(getIncludedIn(result.getCommit().getId()).branches)
.containsExactly("master", "test-branch");
}
@Test
public void cherryPickCommitWithoutChangeId() throws Exception {
// This test is a little superfluous, since the current cherry-pick code ignores
// the commit message of the to-be-cherry-picked change, using the one in
// CherryPickInput instead.
CherryPickInput input = new CherryPickInput();
input.destination = "foo";
input.message = "it goes to foo branch";
gApi.projects().name(project.get()).branch(input.destination).create(new BranchInput());
RevCommit revCommit = createNewCommitWithoutChangeId("refs/heads/master", "a.txt", "content");
ChangeInfo changeInfo =
gApi.projects().name(project.get()).commit(revCommit.getName()).cherryPick(input).get();
assertThat(changeInfo.messages).hasSize(1);
Iterator<ChangeMessageInfo> messageIterator = changeInfo.messages.iterator();
String expectedMessage =
String.format("Patch Set 1: Cherry Picked from commit %s.", revCommit.getName());
assertThat(messageIterator.next().message).isEqualTo(expectedMessage);
RevisionInfo revInfo = changeInfo.revisions.get(changeInfo.currentRevision);
assertThat(revInfo).isNotNull();
CommitInfo commitInfo = revInfo.commit;
assertThat(commitInfo.message)
.isEqualTo(input.message + "\n\nChange-Id: " + changeInfo.changeId + "\n");
}
@Test
public void cherryPickCommitWithChangeId() throws Exception {
CherryPickInput input = new CherryPickInput();
input.destination = "foo";
RevCommit revCommit = createChange().getCommit();
List<String> footers = revCommit.getFooterLines("Change-Id");
assertThat(footers).hasSize(1);
String changeId = footers.get(0);
input.message = "it goes to foo branch\n\nChange-Id: " + changeId;
gApi.projects().name(project.get()).branch(input.destination).create(new BranchInput());
ChangeInfo changeInfo =
gApi.projects().name(project.get()).commit(revCommit.getName()).cherryPick(input).get();
assertThat(changeInfo.messages).hasSize(1);
Iterator<ChangeMessageInfo> messageIterator = changeInfo.messages.iterator();
String expectedMessage =
String.format("Patch Set 1: Cherry Picked from commit %s.", revCommit.getName());
assertThat(messageIterator.next().message).isEqualTo(expectedMessage);
RevisionInfo revInfo = changeInfo.revisions.get(changeInfo.currentRevision);
assertThat(revInfo).isNotNull();
assertThat(revInfo.commit.message).isEqualTo(input.message + "\n");
}
private IncludedInInfo getIncludedIn(ObjectId id) throws Exception {
return gApi.projects().name(project.get()).commit(id.name()).includedIn();
}
private static void assertPerson(GitPerson actual, TestAccount expected) {
assertThat(actual.email).isEqualTo(expected.email);
assertThat(actual.name).isEqualTo(expected.fullName);
}
}

View File

@@ -1,66 +0,0 @@
// Copyright (C) 2017 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.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.common.data.Permission;
import com.google.gerrit.extensions.api.changes.IncludedInInfo;
import com.google.gerrit.extensions.api.changes.ReviewInput;
import com.google.gerrit.extensions.api.projects.TagInput;
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 {
Result result = createChange();
assertThat(getIncludedIn(result.getCommit().getId()).branches).isEmpty();
assertThat(getIncludedIn(result.getCommit().getId()).tags).isEmpty();
}
@Test
public void includedInMergedChange() throws Exception {
Result result = createChange();
gApi.changes()
.id(result.getChangeId())
.revision(result.getCommit().name())
.review(ReviewInput.approve());
gApi.changes().id(result.getChangeId()).revision(result.getCommit().name()).submit();
assertThat(getIncludedIn(result.getCommit().getId()).branches).containsExactly("master");
assertThat(getIncludedIn(result.getCommit().getId()).tags).isEmpty();
grant(project, R_TAGS + "*", Permission.CREATE_TAG);
gApi.projects().name(result.getChange().project().get()).tag("test-tag").create(new TagInput());
assertThat(getIncludedIn(result.getCommit().getId()).tags).containsExactly("test-tag");
createBranch(new Branch.NameKey(project.get(), "test-branch"));
assertThat(getIncludedIn(result.getCommit().getId()).branches)
.containsExactly("master", "test-branch");
}
private IncludedInInfo getIncludedIn(ObjectId id) throws Exception {
return gApi.projects().name(project.get()).commit(id.name()).includedIn();
}
}

View File

@@ -26,6 +26,7 @@ import static com.google.gerrit.extensions.client.ListChangesOption.DETAILED_LAB
import static com.google.gerrit.reviewdb.client.Patch.COMMIT_MSG;
import static com.google.gerrit.reviewdb.client.Patch.MERGE_LIST;
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
import static com.google.gerrit.testing.GerritJUnit.assertThrows;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.stream.Collectors.toList;
import static org.eclipse.jgit.lib.Constants.HEAD;
@@ -1054,30 +1055,76 @@ public class RevisionIT extends AbstractDaemonTest {
PushOneCommit.Result r = createChange();
Map<String, FileInfo> files =
gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).files();
assertThat(files).hasSize(2);
assertThat(Iterables.all(files.keySet(), f -> f.matches(FILE_NAME + '|' + COMMIT_MSG)))
.isTrue();
assertThat(files.keySet()).containsExactly(FILE_NAME, COMMIT_MSG);
}
@Test
public void filesOnMergeCommitChange() throws Exception {
PushOneCommit.Result r = createMergeCommitChange("refs/for/master");
// list files against auto-merge
// List files against auto-merge
assertThat(gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).files().keySet())
.containsExactly(COMMIT_MSG, MERGE_LIST, "foo", "bar");
// list files against parent 1
// List files against parent 1
assertThat(gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).files(1).keySet())
.containsExactly(COMMIT_MSG, MERGE_LIST, "bar");
// list files against parent 2
// List files against parent 2
assertThat(gApi.changes().id(r.getChangeId()).revision(r.getCommit().name()).files(2).keySet())
.containsExactly(COMMIT_MSG, MERGE_LIST, "foo");
}
@Test
public void filesOnMergeCommitChangeWithInvalidParent() throws Exception {
PushOneCommit.Result r = createMergeCommitChange("refs/for/master");
BadRequestException thrown =
assertThrows(
BadRequestException.class,
() ->
gApi.changes()
.id(r.getChangeId())
.revision(r.getCommit().name())
.files(3)
.keySet());
assertThat(thrown).hasMessageThat().isEqualTo("invalid parent number: 3");
thrown =
assertThrows(
BadRequestException.class,
() ->
gApi.changes()
.id(r.getChangeId())
.revision(r.getCommit().name())
.files(-1)
.keySet());
assertThat(thrown).hasMessageThat().isEqualTo("invalid parent number: -1");
}
@Test
public void listFilesWithInvalidParent() throws Exception {
PushOneCommit.Result result1 = createChange();
String changeId = result1.getChangeId();
PushOneCommit.Result result2 = amendChange(changeId, SUBJECT, "b.txt", "b");
String revId2 = result2.getCommit().name();
BadRequestException thrown =
assertThrows(
BadRequestException.class,
() -> gApi.changes().id(changeId).revision(revId2).files(2).keySet());
assertThat(thrown).hasMessageThat().isEqualTo("invalid parent number: 2");
thrown =
assertThrows(
BadRequestException.class,
() -> gApi.changes().id(changeId).revision(revId2).files(-1).keySet());
assertThat(thrown).hasMessageThat().isEqualTo("invalid parent number: -1");
}
@Test
public void listFilesOnDifferentBases() throws Exception {
RevCommit initialCommit = getHead(repo());
PushOneCommit.Result result1 = createChange();
String changeId = result1.getChangeId();
PushOneCommit.Result result2 = amendChange(changeId, SUBJECT, "b.txt", "b");
@@ -1100,6 +1147,19 @@ public class RevisionIT extends AbstractDaemonTest {
.containsExactly(COMMIT_MSG, "b.txt", "c.txt");
assertThat(gApi.changes().id(changeId).revision(revId3).files(revId2).keySet())
.containsExactly(COMMIT_MSG, "c.txt");
ResourceNotFoundException thrown =
assertThrows(
ResourceNotFoundException.class,
() -> gApi.changes().id(changeId).revision(revId3).files(initialCommit.getName()));
assertThat(thrown).hasMessageThat().contains(initialCommit.getName());
String invalidRev = "deadbeef";
thrown =
assertThrows(
ResourceNotFoundException.class,
() -> gApi.changes().id(changeId).revision(revId3).files(invalidRev));
assertThat(thrown).hasMessageThat().contains(invalidRev);
}
@Test

View File

@@ -32,7 +32,7 @@ public class ElasticReindexIT extends AbstractReindexTests {
@ConfigSuite.Config
public static Config elasticsearchV6() {
return getConfig(ElasticVersion.V6_7);
return getConfig(ElasticVersion.V6_8);
}
@ConfigSuite.Config

View File

@@ -32,15 +32,11 @@ import com.google.gerrit.extensions.api.changes.ChangeApi;
import com.google.gerrit.extensions.api.changes.CherryPickInput;
import com.google.gerrit.extensions.api.changes.NotifyHandling;
import com.google.gerrit.extensions.api.changes.ReviewInput;
import com.google.gerrit.extensions.api.projects.BranchInput;
import com.google.gerrit.extensions.client.ChangeStatus;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.ChangeInput;
import com.google.gerrit.extensions.common.ChangeMessageInfo;
import com.google.gerrit.extensions.common.CommitInfo;
import com.google.gerrit.extensions.common.MergeInput;
import com.google.gerrit.extensions.common.RevisionInfo;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.extensions.restapi.ResourceConflictException;
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
@@ -51,7 +47,6 @@ import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.server.submit.ChangeAlreadyMergedException;
import com.google.gerrit.testing.FakeEmailSender.Message;
import com.google.gerrit.testing.TestTimeUtil;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.jgit.lib.ObjectId;
@@ -401,60 +396,6 @@ public class CreateChangeIT extends AbstractDaemonTest {
assertCreateSucceeds(in);
}
@Test
public void cherryPickCommitWithoutChangeId() throws Exception {
// This test is a little superfluous, since the current cherry-pick code ignores
// the commit message of the to-be-cherry-picked change, using the one in
// CherryPickInput instead.
CherryPickInput input = new CherryPickInput();
input.destination = "foo";
input.message = "it goes to foo branch";
gApi.projects().name(project.get()).branch(input.destination).create(new BranchInput());
RevCommit revCommit = createNewCommitWithoutChangeId("refs/heads/master", "a.txt", "content");
ChangeInfo changeInfo =
gApi.projects().name(project.get()).commit(revCommit.getName()).cherryPick(input).get();
assertThat(changeInfo.messages).hasSize(1);
Iterator<ChangeMessageInfo> messageIterator = changeInfo.messages.iterator();
String expectedMessage =
String.format("Patch Set 1: Cherry Picked from commit %s.", revCommit.getName());
assertThat(messageIterator.next().message).isEqualTo(expectedMessage);
RevisionInfo revInfo = changeInfo.revisions.get(changeInfo.currentRevision);
assertThat(revInfo).isNotNull();
CommitInfo commitInfo = revInfo.commit;
assertThat(commitInfo.message)
.isEqualTo(input.message + "\n\nChange-Id: " + changeInfo.changeId + "\n");
}
@Test
public void cherryPickCommitWithChangeId() throws Exception {
CherryPickInput input = new CherryPickInput();
input.destination = "foo";
RevCommit revCommit = createChange().getCommit();
List<String> footers = revCommit.getFooterLines("Change-Id");
assertThat(footers).hasSize(1);
String changeId = footers.get(0);
input.message = "it goes to foo branch\n\nChange-Id: " + changeId;
gApi.projects().name(project.get()).branch(input.destination).create(new BranchInput());
ChangeInfo changeInfo =
gApi.projects().name(project.get()).commit(revCommit.getName()).cherryPick(input).get();
assertThat(changeInfo.messages).hasSize(1);
Iterator<ChangeMessageInfo> messageIterator = changeInfo.messages.iterator();
String expectedMessage =
String.format("Patch Set 1: Cherry Picked from commit %s.", revCommit.getName());
assertThat(messageIterator.next().message).isEqualTo(expectedMessage);
RevisionInfo revInfo = changeInfo.revisions.get(changeInfo.currentRevision);
assertThat(revInfo).isNotNull();
assertThat(revInfo.commit.message).isEqualTo(input.message + "\n");
}
private ChangeInput newChangeInput(ChangeStatus status) {
ChangeInput in = new ChangeInput();
in.project = project.get();

View File

@@ -31,7 +31,7 @@ public class ElasticIndexIT extends AbstractIndexTests {
@ConfigSuite.Config
public static Config elasticsearchV6() {
return getConfig(ElasticVersion.V6_7);
return getConfig(ElasticVersion.V6_8);
}
@ConfigSuite.Config

View File

@@ -50,12 +50,14 @@ public class ElasticContainer extends ElasticsearchContainer {
return "blacktop/elasticsearch:6.6.2";
case V6_7:
return "blacktop/elasticsearch:6.7.2";
case V6_8:
return "blacktop/elasticsearch:6.8.2";
case V7_0:
return "blacktop/elasticsearch:7.0.1";
case V7_1:
return "blacktop/elasticsearch:7.1.1";
case V7_2:
return "blacktop/elasticsearch:7.2.0";
return "blacktop/elasticsearch:7.2.1";
}
throw new IllegalStateException("No tests for version: " + version.name());
}

View File

@@ -41,7 +41,7 @@ public class ElasticV6QueryAccountsTest extends AbstractQueryAccountsTest {
return;
}
container = ElasticContainer.createAndStart(ElasticVersion.V6_7);
container = ElasticContainer.createAndStart(ElasticVersion.V6_8);
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
}

View File

@@ -41,7 +41,7 @@ public class ElasticV6QueryChangesTest extends AbstractQueryChangesTest {
return;
}
container = ElasticContainer.createAndStart(ElasticVersion.V6_7);
container = ElasticContainer.createAndStart(ElasticVersion.V6_8);
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
}

View File

@@ -41,7 +41,7 @@ public class ElasticV6QueryGroupsTest extends AbstractQueryGroupsTest {
return;
}
container = ElasticContainer.createAndStart(ElasticVersion.V6_7);
container = ElasticContainer.createAndStart(ElasticVersion.V6_8);
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
}

View File

@@ -41,7 +41,7 @@ public class ElasticV6QueryProjectsTest extends AbstractQueryProjectsTest {
return;
}
container = ElasticContainer.createAndStart(ElasticVersion.V6_7);
container = ElasticContainer.createAndStart(ElasticVersion.V6_8);
nodeInfo = new ElasticNodeInfo(container.getHttpHost().getPort());
}

View File

@@ -46,6 +46,9 @@ public class ElasticVersionTest {
assertThat(ElasticVersion.forVersion("6.7.0")).isEqualTo(ElasticVersion.V6_7);
assertThat(ElasticVersion.forVersion("6.7.1")).isEqualTo(ElasticVersion.V6_7);
assertThat(ElasticVersion.forVersion("6.8.0")).isEqualTo(ElasticVersion.V6_8);
assertThat(ElasticVersion.forVersion("6.8.1")).isEqualTo(ElasticVersion.V6_8);
assertThat(ElasticVersion.forVersion("7.0.0")).isEqualTo(ElasticVersion.V7_0);
assertThat(ElasticVersion.forVersion("7.0.1")).isEqualTo(ElasticVersion.V7_0);
@@ -73,6 +76,7 @@ public class ElasticVersionTest {
assertThat(ElasticVersion.V6_5.isAtLeastMinorVersion(ElasticVersion.V6_7)).isFalse();
assertThat(ElasticVersion.V6_6.isAtLeastMinorVersion(ElasticVersion.V6_7)).isFalse();
assertThat(ElasticVersion.V6_7.isAtLeastMinorVersion(ElasticVersion.V6_7)).isTrue();
assertThat(ElasticVersion.V6_8.isAtLeastMinorVersion(ElasticVersion.V6_8)).isTrue();
assertThat(ElasticVersion.V7_0.isAtLeastMinorVersion(ElasticVersion.V6_7)).isFalse();
assertThat(ElasticVersion.V7_1.isAtLeastMinorVersion(ElasticVersion.V6_7)).isFalse();
assertThat(ElasticVersion.V7_2.isAtLeastMinorVersion(ElasticVersion.V6_7)).isFalse();
@@ -87,6 +91,7 @@ public class ElasticVersionTest {
assertThat(ElasticVersion.V6_5.isV6OrLater()).isTrue();
assertThat(ElasticVersion.V6_6.isV6OrLater()).isTrue();
assertThat(ElasticVersion.V6_7.isV6OrLater()).isTrue();
assertThat(ElasticVersion.V6_8.isV6OrLater()).isTrue();
assertThat(ElasticVersion.V7_0.isV6OrLater()).isTrue();
assertThat(ElasticVersion.V7_1.isV6OrLater()).isTrue();
assertThat(ElasticVersion.V7_2.isV6OrLater()).isTrue();
@@ -101,6 +106,7 @@ public class ElasticVersionTest {
assertThat(ElasticVersion.V6_5.isV7OrLater()).isFalse();
assertThat(ElasticVersion.V6_6.isV7OrLater()).isFalse();
assertThat(ElasticVersion.V6_7.isV7OrLater()).isFalse();
assertThat(ElasticVersion.V6_8.isV7OrLater()).isFalse();
assertThat(ElasticVersion.V7_0.isV7OrLater()).isTrue();
assertThat(ElasticVersion.V7_1.isV7OrLater()).isTrue();
assertThat(ElasticVersion.V7_2.isV7OrLater()).isTrue();